Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f381ce96
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f381ce96
编写于
7月 07, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add API to open a file or diff editor on a specific selection range (fixes #30241)
上级
6af04818
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
37 addition
and
10 deletion
+37
-10
extensions/vscode-api-tests/src/commands.test.ts
extensions/vscode-api-tests/src/commands.test.ts
+9
-4
extensions/vscode-api-tests/src/workspace.test.ts
extensions/vscode-api-tests/src/workspace.test.ts
+13
-0
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+5
-0
src/vs/workbench/api/electron-browser/mainThreadEditors.ts
src/vs/workbench/api/electron-browser/mainThreadEditors.ts
+4
-3
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-0
src/vs/workbench/api/node/extHostApiCommands.ts
src/vs/workbench/api/node/extHostApiCommands.ts
+4
-3
src/vs/workbench/api/node/extHostTextEditors.ts
src/vs/workbench/api/node/extHostTextEditors.ts
+1
-0
未找到文件。
extensions/vscode-api-tests/src/commands.test.ts
浏览文件 @
f381ce96
...
...
@@ -7,7 +7,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
join
}
from
'
path
'
;
import
{
commands
,
workspace
,
window
,
Uri
,
ViewColumn
}
from
'
vscode
'
;
import
{
commands
,
workspace
,
window
,
Uri
,
ViewColumn
,
Range
,
Position
}
from
'
vscode
'
;
suite
(
'
commands namespace tests
'
,
()
=>
{
...
...
@@ -114,10 +114,15 @@ suite('commands namespace tests', () => {
registration
.
dispose
();
});
let
c
=
commands
.
executeCommand
(
'
vscode.diff
'
).
then
(()
=>
assert
.
ok
(
false
),
()
=>
assert
.
ok
(
true
));
let
d
=
commands
.
executeCommand
(
'
vscode.diff
'
,
1
,
2
,
3
).
then
(()
=>
assert
.
ok
(
false
),
()
=>
assert
.
ok
(
true
));
let
c
=
commands
.
executeCommand
(
'
vscode.diff
'
,
Uri
.
parse
(
'
sc:a
'
),
Uri
.
parse
(
'
sc:b
'
),
'
Title
'
,
{
selection
:
new
Range
(
new
Position
(
1
,
1
),
new
Position
(
1
,
2
))
}).
then
(
value
=>
{
assert
.
ok
(
value
===
void
0
);
registration
.
dispose
();
});
return
Promise
.
all
([
a
,
b
,
c
,
d
]);
let
d
=
commands
.
executeCommand
(
'
vscode.diff
'
).
then
(()
=>
assert
.
ok
(
false
),
()
=>
assert
.
ok
(
true
));
let
e
=
commands
.
executeCommand
(
'
vscode.diff
'
,
1
,
2
,
3
).
then
(()
=>
assert
.
ok
(
false
),
()
=>
assert
.
ok
(
true
));
return
Promise
.
all
([
a
,
b
,
c
,
d
,
e
]);
});
test
(
'
api-command: vscode.open
'
,
function
()
{
...
...
extensions/vscode-api-tests/src/workspace.test.ts
浏览文件 @
f381ce96
...
...
@@ -260,6 +260,19 @@ suite('workspace-namespace', () => {
});
});
test
(
'
openTextDocument, with selection
'
,
function
()
{
return
createRandomFile
(
'
foo
\n
bar
\n
bar
'
).
then
(
file
=>
{
return
vscode
.
workspace
.
openTextDocument
(
file
).
then
(
doc
=>
{
return
vscode
.
window
.
showTextDocument
(
doc
,
{
selection
:
new
vscode
.
Range
(
new
vscode
.
Position
(
1
,
1
),
new
vscode
.
Position
(
1
,
2
))
}).
then
(
editor
=>
{
assert
.
equal
(
editor
.
selection
.
start
.
line
,
1
);
assert
.
equal
(
editor
.
selection
.
start
.
character
,
1
);
assert
.
equal
(
editor
.
selection
.
end
.
line
,
1
);
assert
.
equal
(
editor
.
selection
.
end
.
character
,
2
);
});
});
});
});
test
(
'
registerTextDocumentContentProvider, simple
'
,
function
()
{
let
registration
=
vscode
.
workspace
.
registerTextDocumentContentProvider
(
'
foo
'
,
{
...
...
src/vs/vscode.d.ts
浏览文件 @
f381ce96
...
...
@@ -743,6 +743,11 @@ declare module 'vscode' {
* with the next editor or if it will be kept.
*/
preview
?:
boolean
;
/**
* An optional selection to apply for the document in the [editor](#TextEditor).
*/
selection
?:
Range
;
}
/**
...
...
src/vs/workbench/api/electron-browser/mainThreadEditors.ts
浏览文件 @
f381ce96
...
...
@@ -12,7 +12,7 @@ import { ISingleEditOperation, IDecorationRenderOptions, IDecorationOptions, ILi
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorOptions
,
Position
as
EditorPosition
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
as
EditorPosition
,
ITextEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
MainThreadTextEditor
}
from
'
./mainThreadEditor
'
;
import
{
ITextEditorConfigurationUpdate
,
TextEditorRevealType
,
IApplyEditsOptions
,
IUndoStopOptions
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
...
...
@@ -107,9 +107,10 @@ export class MainThreadEditors extends MainThreadEditorsShape {
// --- from extension host process
$tryShowTextDocument
(
resource
:
URI
,
options
:
ITextDocumentShowOptions
):
TPromise
<
string
>
{
const
editorOptions
:
IEditorOptions
=
{
const
editorOptions
:
I
Text
EditorOptions
=
{
preserveFocus
:
options
.
preserveFocus
,
pinned
:
options
.
pinned
pinned
:
options
.
pinned
,
selection
:
options
.
selection
};
const
input
=
{
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
f381ce96
...
...
@@ -183,6 +183,7 @@ export interface ITextDocumentShowOptions {
position
?:
EditorPosition
;
preserveFocus
?:
boolean
;
pinned
?:
boolean
;
selection
?:
IRange
;
}
export
abstract
class
MainThreadEditorsShape
{
...
...
src/vs/workbench/api/node/extHostApiCommands.ts
浏览文件 @
f381ce96
...
...
@@ -15,7 +15,7 @@ import * as modes from 'vs/editor/common/modes';
import
{
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
IWorkspaceSymbolProvider
}
from
'
vs/workbench/parts/search/common/search
'
;
import
{
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
I
Text
EditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
export
class
ExtHostApiCommands
{
...
...
@@ -205,11 +205,12 @@ export class ExtHostApiCommands {
});
this
.
_register
(
'
vscode.diff
'
,
(
left
:
URI
,
right
:
URI
,
label
:
string
,
options
?:
vscode
.
TextDocumentShowOptions
)
=>
{
let
editorOptions
:
IEditorOptions
;
let
editorOptions
:
I
Text
EditorOptions
;
if
(
options
)
{
editorOptions
=
{
pinned
:
typeof
options
.
preview
===
'
boolean
'
?
!
options
.
preview
:
undefined
,
preserveFocus
:
options
.
preserveFocus
preserveFocus
:
options
.
preserveFocus
,
selection
:
typeof
options
.
selection
===
'
object
'
?
typeConverters
.
fromRange
(
options
.
selection
)
:
undefined
};
}
...
...
src/vs/workbench/api/node/extHostTextEditors.ts
浏览文件 @
f381ce96
...
...
@@ -69,6 +69,7 @@ export class ExtHostEditors extends ExtHostEditorsShape {
options
=
{
position
:
TypeConverters
.
fromViewColumn
(
columnOrOptions
.
viewColumn
),
preserveFocus
:
columnOrOptions
.
preserveFocus
,
selection
:
typeof
columnOrOptions
.
selection
===
'
object
'
?
TypeConverters
.
fromRange
(
columnOrOptions
.
selection
)
:
undefined
,
pinned
:
typeof
columnOrOptions
.
preview
===
'
boolean
'
?
!
columnOrOptions
.
preview
:
undefined
};
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录