Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5f44e365
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f44e365
编写于
4月 06, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix issue #4945
上级
24fb832c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
10 deletion
+33
-10
extensions/vscode-api-tests/src/commands.test.ts
extensions/vscode-api-tests/src/commands.test.ts
+27
-5
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+1
-1
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+5
-4
未找到文件。
extensions/vscode-api-tests/src/commands.test.ts
浏览文件 @
5f44e365
...
...
@@ -6,9 +6,10 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
commands
,
workspace
,
Uri
}
from
'
vscode
'
;
import
{
join
}
from
'
path
'
;
import
{
commands
,
workspace
,
window
,
Uri
}
from
'
vscode
'
;
suite
(
"
commands namespace tests
"
,
()
=>
{
suite
(
'
commands namespace tests
'
,
()
=>
{
test
(
'
getCommands
'
,
function
(
done
)
{
...
...
@@ -39,7 +40,7 @@ suite("commands namespace tests", () => {
},
done
);
});
test
(
'
api-command: workbench.html.preview
'
,
function
()
{
test
(
'
api-command: workbench.html.preview
'
,
function
()
{
let
registration
=
workspace
.
registerTextDocumentContentProvider
(
'
speciale
'
,
{
provideTextDocumentContent
(
uri
)
{
...
...
@@ -47,12 +48,33 @@ suite("commands namespace tests", () => {
}
});
let
virtualDocumentUri
=
Uri
.
parse
(
'
speciale://authority/path
'
)
let
virtualDocumentUri
=
Uri
.
parse
(
'
speciale://authority/path
'
)
;
return
commands
.
executeCommand
(
'
vscode.previewHtml
'
,
virtualDocumentUri
).
then
(
success
=>
{
assert
.
ok
(
success
);
registration
.
dispose
();
});
})
});
test
(
'
editorCommand with extra args
'
,
function
()
{
let
args
:
IArguments
;
let
registration
=
commands
.
registerTextEditorCommand
(
'
t1
'
,
function
()
{
args
=
arguments
;
});
return
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
,
'
./far.js
'
)).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
).
then
(
editor
=>
{
return
commands
.
executeCommand
(
'
t1
'
,
12345
,
commands
);
}).
then
(()
=>
{
assert
.
ok
(
args
);
assert
.
equal
(
args
.
length
,
4
);
assert
.
ok
(
args
[
2
]
===
12345
);
assert
.
ok
(
args
[
3
]
===
commands
);
registration
.
dispose
();
});
});
});
});
src/vs/vscode.d.ts
浏览文件 @
5f44e365
...
...
@@ -2865,7 +2865,7 @@ declare namespace vscode {
* @param thisArg The `this` context used when invoking the handler function.
* @return Disposable which unregisters this command on disposal.
*/
export
function
registerTextEditorCommand
(
command
:
string
,
callback
:
(
textEditor
:
TextEditor
,
edit
:
TextEditorEdit
)
=>
void
,
thisArg
?:
any
):
Disposable
;
export
function
registerTextEditorCommand
(
command
:
string
,
callback
:
(
textEditor
:
TextEditor
,
edit
:
TextEditorEdit
,
...
args
:
any
[]
)
=>
void
,
thisArg
?:
any
):
Disposable
;
/**
* Executes the command denoted by the given command identifier.
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
5f44e365
...
...
@@ -162,9 +162,8 @@ export class ExtHostAPIImplementation {
registerCommand
<
T
>
(
id
:
string
,
command
:
<
T
>
(...
args
:
any
[])
=>
T
|
Thenable
<
T
>
,
thisArgs
?:
any
):
vscode
.
Disposable
{
return
extHostCommands
.
registerCommand
(
id
,
command
,
thisArgs
);
},
registerTextEditorCommand
(
id
:
string
,
callback
:
(
textEditor
:
vscode
.
TextEditor
,
edit
:
vscode
.
TextEditorEdit
)
=>
void
,
thisArg
?:
any
):
vscode
.
Disposable
{
let
actualCallback
:
typeof
callback
=
thisArg
?
callback
.
bind
(
thisArg
)
:
callback
;
return
extHostCommands
.
registerCommand
(
id
,
()
=>
{
registerTextEditorCommand
(
id
:
string
,
callback
:
(
textEditor
:
vscode
.
TextEditor
,
edit
:
vscode
.
TextEditorEdit
,
...
args
:
any
[])
=>
void
,
thisArg
?:
any
):
vscode
.
Disposable
{
return
extHostCommands
.
registerCommand
(
id
,
(...
args
:
any
[])
=>
{
let
activeTextEditor
=
extHostEditors
.
getActiveTextEditor
();
if
(
!
activeTextEditor
)
{
console
.
warn
(
'
Cannot execute
'
+
id
+
'
because there is no active text editor.
'
);
...
...
@@ -172,7 +171,9 @@ export class ExtHostAPIImplementation {
}
activeTextEditor
.
edit
((
edit
:
vscode
.
TextEditorEdit
)
=>
{
actualCallback
(
activeTextEditor
,
edit
);
args
.
unshift
(
activeTextEditor
,
edit
);
callback
.
apply
(
thisArg
,
args
);
}).
then
((
result
)
=>
{
if
(
!
result
)
{
console
.
warn
(
'
Edits from command
'
+
id
+
'
were not applied.
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录