Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
d8f6ac35
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
d8f6ac35
编写于
5月 17, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add new api command to compare two resources, fixes #1865
上级
6af3db5d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
79 addition
and
15 deletion
+79
-15
extensions/vscode-api-tests/src/commands.test.ts
extensions/vscode-api-tests/src/commands.test.ts
+40
-15
src/vs/workbench/api/node/extHostApiCommands.ts
src/vs/workbench/api/node/extHostApiCommands.ts
+11
-0
src/vs/workbench/electron-browser/actions.ts
src/vs/workbench/electron-browser/actions.ts
+28
-0
未找到文件。
extensions/vscode-api-tests/src/commands.test.ts
浏览文件 @
d8f6ac35
...
...
@@ -40,7 +40,28 @@ suite('commands namespace tests', () => {
},
done
);
});
test
(
'
api-command: workbench.html.preview
'
,
function
()
{
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
();
});
});
});
test
(
'
api-command: vscode.previewHtm
'
,
function
()
{
let
registration
=
workspace
.
registerTextDocumentContentProvider
(
'
speciale
'
,
{
provideTextDocumentContent
(
uri
)
{
...
...
@@ -57,24 +78,28 @@ suite('commands namespace tests', () => {
});
test
(
'
editorCommand with extra args
'
,
function
()
{
test
(
'
api-command: vscode.diff
'
,
function
()
{
let
args
:
IArguments
;
let
registration
=
commands
.
registerTextEditorCommand
(
'
t1
'
,
function
()
{
args
=
arguments
;
let
registration
=
workspace
.
registerTextDocumentContentProvider
(
'
sc
'
,
{
provideTextDocumentContent
(
uri
)
{
return
`content of URI <b>
${
uri
.
toString
()}
</b>#
${
Math
.
random
()}
`
;
}
});
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
();
});
let
a
=
commands
.
executeCommand
(
'
vscode.diff
'
,
Uri
.
parse
(
'
sc:a
'
),
Uri
.
parse
(
'
sc:b
'
),
'
DIFF
'
).
then
(
value
=>
{
assert
.
ok
(
value
===
void
0
);
registration
.
dispose
();
});
let
b
=
commands
.
executeCommand
(
'
vscode.diff
'
,
Uri
.
parse
(
'
sc:a
'
),
Uri
.
parse
(
'
sc:b
'
)).
then
(
value
=>
{
assert
.
ok
(
value
===
void
0
);
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
));
return
Promise
.
all
([
a
,
b
,
c
]);
});
});
src/vs/workbench/api/node/extHostApiCommands.ts
浏览文件 @
d8f6ac35
...
...
@@ -197,6 +197,17 @@ class ExtHostApiCommands {
{
name
:
'
configuration
'
,
description
:
'
(optional) Name of the debug configuration from
\'
launch.json
\'
to use. Or a configuration json object to use.
'
}
]
});
this
.
_register
(
'
vscode.diff
'
,
(
left
:
URI
,
right
:
URI
,
label
:
string
)
=>
{
return
this
.
_commands
.
executeCommand
(
'
_workbench.diff
'
,
[
left
,
right
,
label
]);
},
{
description
:
'
Opens the provided resources in the diff editor to compare their contents.
'
,
args
:
[
{
name
:
'
left
'
,
description
:
'
Left-hand side resource of the diff editor
'
,
constraint
:
URI
},
{
name
:
'
right
'
,
description
:
'
Right-hand side resource of the diff editor
'
,
constraint
:
URI
},
{
name
:
'
title
'
,
description
:
'
(optional) Human readable title for the diff editor
'
,
constraint
:
v
=>
v
===
void
0
||
typeof
v
===
'
string
'
}
]
});
}
// --- command impl
...
...
src/vs/workbench/electron-browser/actions.ts
浏览文件 @
d8f6ac35
...
...
@@ -5,12 +5,15 @@
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
timer
=
require
(
'
vs/base/common/timer
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
IWindowService
}
from
'
vs/workbench/services/window/electron-browser/windowService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
IWindowConfiguration
}
from
'
vs/workbench/electron-browser/window
'
;
...
...
@@ -459,4 +462,29 @@ KeybindingsRegistry.registerCommandDesc({
},
when
:
undefined
,
primary
:
undefined
});
KeybindingsRegistry
.
registerCommandDesc
({
id
:
'
_workbench.diff
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
0
),
handler
(
accessor
:
ServicesAccessor
,
args
:
[
URI
,
URI
,
string
])
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
let
[
left
,
right
,
label
]
=
args
;
if
(
!
label
)
{
label
=
nls
.
localize
(
'
diffLeftRightLabel
'
,
"
{0} ⟷ {1}
"
,
left
.
toString
(
true
),
right
.
toString
(
true
));
}
return
TPromise
.
join
([
editorService
.
inputToType
({
resource
:
left
}),
editorService
.
inputToType
({
resource
:
right
})]).
then
(
inputs
=>
{
const
[
left
,
right
]
=
inputs
;
const
diff
=
new
DiffEditorInput
(
label
,
undefined
,
<
EditorInput
>
left
,
<
EditorInput
>
right
);
return
editorService
.
openEditor
(
diff
);
}).
then
(()
=>
{
return
void
0
;
});
},
when
:
undefined
,
primary
:
undefined
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录