Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d86955c7
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,发现更多精彩内容 >>
提交
d86955c7
编写于
10月 03, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move id into ICommand
上级
78e64e72
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
44 addition
and
35 deletion
+44
-35
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
...editor/contrib/referenceSearch/browser/referenceSearch.ts
+6
-2
src/vs/editor/standalone/browser/simpleServices.ts
src/vs/editor/standalone/browser/simpleServices.ts
+4
-2
src/vs/platform/commands/common/commands.ts
src/vs/platform/commands/common/commands.ts
+25
-25
src/vs/platform/commands/test/commandService.test.ts
src/vs/platform/commands/test/commandService.test.ts
+2
-1
src/vs/platform/commands/test/commands.test.ts
src/vs/platform/commands/test/commands.test.ts
+4
-2
src/vs/platform/keybinding/common/keybindingsRegistry.ts
src/vs/platform/keybinding/common/keybindingsRegistry.ts
+1
-1
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
.../parts/terminal/electron-browser/terminal.contribution.ts
+2
-2
未找到文件。
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
浏览文件 @
d86955c7
...
...
@@ -143,9 +143,13 @@ let showReferencesCommand: ICommandHandler = (accessor: ServicesAccessor, resour
// register commands
CommandsRegistry
.
registerCommand
(
'
editor.action.findReferences
'
,
findReferencesCommand
);
CommandsRegistry
.
registerCommand
({
id
:
'
editor.action.findReferences
'
,
handler
:
findReferencesCommand
});
CommandsRegistry
.
registerCommand
(
'
editor.action.showReferences
'
,
{
CommandsRegistry
.
registerCommand
({
id
:
'
editor.action.showReferences
'
,
handler
:
showReferencesCommand
,
description
:
{
description
:
'
Show references at a position in a file
'
,
...
...
src/vs/editor/standalone/browser/simpleServices.ts
浏览文件 @
d86955c7
...
...
@@ -285,7 +285,8 @@ export class StandaloneCommandService implements ICommandService {
this
.
_dynamicCommands
=
Object
.
create
(
null
);
}
public
addCommand
(
id
:
string
,
command
:
ICommand
):
IDisposable
{
public
addCommand
(
command
:
ICommand
):
IDisposable
{
const
{
id
}
=
command
;
this
.
_dynamicCommands
[
id
]
=
command
;
return
{
dispose
:
()
=>
{
...
...
@@ -360,7 +361,8 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
let
commandService
=
this
.
_commandService
;
if
(
commandService
instanceof
StandaloneCommandService
)
{
toDispose
.
push
(
commandService
.
addCommand
(
commandId
,
{
toDispose
.
push
(
commandService
.
addCommand
({
id
:
commandId
,
handler
:
handler
}));
}
else
{
...
...
src/vs/platform/commands/common/commands.ts
浏览文件 @
d86955c7
...
...
@@ -33,6 +33,7 @@ export interface ICommandHandler {
}
export
interface
ICommand
{
id
:
string
;
handler
:
ICommandHandler
;
precondition
?:
ContextKeyExpr
;
description
?:
ICommandHandlerDescription
;
...
...
@@ -46,7 +47,7 @@ export interface ICommandHandlerDescription {
export
interface
ICommandRegistry
{
registerCommand
(
id
:
string
,
command
:
ICommandHandler
):
IDisposable
;
registerCommand
(
id
:
string
,
command
:
ICommand
):
IDisposable
;
registerCommand
(
command
:
ICommand
):
IDisposable
;
getCommand
(
id
:
string
):
ICommand
;
getCommands
():
ICommandsMap
;
}
...
...
@@ -62,42 +63,41 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
private
_commands
=
new
Map
<
string
,
ICommand
|
ICommand
[]
>
();
registerCommand
(
id
:
string
,
commandOrDesc
:
ICommandHandler
|
ICommand
):
IDisposable
{
registerCommand
(
id
OrCommand
:
string
|
ICommand
,
handler
?:
ICommandHandler
):
IDisposable
{
if
(
!
commandOrDesc
)
{
if
(
!
idOrCommand
)
{
throw
new
Error
(
`invalid command`
);
}
let
command
:
ICommand
;
if
(
!
isCommand
(
commandOrDesc
))
{
// simple handler
command
=
{
handler
:
commandOrDesc
};
}
else
{
if
(
commandOrDesc
.
description
)
{
// add argument validation if rich command metadata is provided
const
constraints
:
TypeConstraint
[]
=
[];
for
(
let
arg
of
commandOrDesc
.
description
.
args
)
{
constraints
.
push
(
arg
.
constraint
);
}
const
actualHandler
=
commandOrDesc
.
handler
;
commandOrDesc
.
handler
=
function
(
accessor
,
...
args
:
any
[])
{
validateConstraints
(
args
,
constraints
);
return
actualHandler
(
accessor
,
...
args
);
};
if
(
typeof
idOrCommand
===
'
string
'
)
{
if
(
!
handler
)
{
throw
new
Error
(
`invalid command`
);
}
return
this
.
registerCommand
({
id
:
idOrCommand
,
handler
});
}
command
=
commandOrDesc
;
// add argument validation if rich command metadata is provided
if
(
idOrCommand
.
description
)
{
const
constraints
:
TypeConstraint
[]
=
[];
for
(
let
arg
of
idOrCommand
.
description
.
args
)
{
constraints
.
push
(
arg
.
constraint
);
}
const
actualHandler
=
idOrCommand
.
handler
;
idOrCommand
.
handler
=
function
(
accessor
,
...
args
:
any
[])
{
validateConstraints
(
args
,
constraints
);
return
actualHandler
(
accessor
,
...
args
);
};
}
// find a place to store the command
const
{
id
}
=
idOrCommand
;
const
commandOrArray
=
this
.
_commands
.
get
(
id
);
if
(
commandOrArray
===
void
0
)
{
this
.
_commands
.
set
(
id
,
c
ommand
);
this
.
_commands
.
set
(
id
,
idOrC
ommand
);
}
else
if
(
Array
.
isArray
(
commandOrArray
))
{
commandOrArray
.
unshift
(
c
ommand
);
commandOrArray
.
unshift
(
idOrC
ommand
);
}
else
{
this
.
_commands
.
set
(
id
,
[
c
ommand
,
commandOrArray
]);
this
.
_commands
.
set
(
id
,
[
idOrC
ommand
,
commandOrArray
]);
}
return
{
...
...
@@ -106,7 +106,7 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
if
(
Array
.
isArray
(
commandOrArray
))
{
// remove from array, remove array
// if last element removed
const
idx
=
commandOrArray
.
indexOf
(
c
ommand
);
const
idx
=
commandOrArray
.
indexOf
(
idOrC
ommand
);
if
(
idx
>=
0
)
{
commandOrArray
.
splice
(
idx
,
1
);
if
(
commandOrArray
.
length
===
0
)
{
...
...
src/vs/platform/commands/test/commandService.test.ts
浏览文件 @
d86955c7
...
...
@@ -117,7 +117,8 @@ suite('CommandService', function () {
);
let
counter
=
0
;
let
reg
=
CommandsRegistry
.
registerCommand
(
'
bar
'
,
{
let
reg
=
CommandsRegistry
.
registerCommand
({
id
:
'
bar
'
,
handler
:
()
=>
{
counter
+=
1
;
},
precondition
:
ContextKeyExpr
.
has
(
'
foocontext
'
)
});
...
...
src/vs/platform/commands/test/commands.test.ts
浏览文件 @
d86955c7
...
...
@@ -60,7 +60,8 @@ suite('Command Tests', function () {
assert
.
ok
(
typeof
args
===
'
string
'
);
});
CommandsRegistry
.
registerCommand
(
'
test3
'
,
{
CommandsRegistry
.
registerCommand
({
id
:
'
test3
'
,
handler
:
function
(
accessor
,
args
)
{
return
true
;
},
...
...
@@ -81,7 +82,8 @@ suite('Command Tests', function () {
let
r1
=
CommandsRegistry
.
registerCommand
(
'
foo
'
,
()
=>
{
});
const
precondition
=
new
RawContextKey
<
boolean
>
(
'
ddd
'
,
false
);
let
r2
=
CommandsRegistry
.
registerCommand
(
'
bar
'
,
{
let
r2
=
CommandsRegistry
.
registerCommand
({
id
:
'
bar
'
,
handler
:
()
=>
{
},
precondition
});
...
...
src/vs/platform/keybinding/common/keybindingsRegistry.ts
浏览文件 @
d86955c7
...
...
@@ -162,7 +162,7 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
public
registerCommandAndKeybindingRule
(
desc
:
ICommandAndKeybindingRule
):
void
{
this
.
registerKeybindingRule
(
desc
);
CommandsRegistry
.
registerCommand
(
desc
.
id
,
desc
);
CommandsRegistry
.
registerCommand
(
{
id
:
desc
.
id
,
handler
:
desc
.
handler
}
);
}
private
static
_mightProduceChar
(
keyCode
:
KeyCode
):
boolean
{
...
...
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
浏览文件 @
d86955c7
...
...
@@ -53,11 +53,11 @@ quickOpenRegistry.registerQuickOpenHandler(
const
quickOpenNavigateNextInTerminalPickerId
=
'
workbench.action.quickOpenNavigateNextInTerminalPicker
'
;
CommandsRegistry
.
registerCommand
(
quickOpenNavigateNextInTerminalPickerId
,
{
handler
:
getQuickNavigateHandler
(
quickOpenNavigateNextInTerminalPickerId
,
true
)
});
{
id
:
quickOpenNavigateNextInTerminalPickerId
,
handler
:
getQuickNavigateHandler
(
quickOpenNavigateNextInTerminalPickerId
,
true
)
});
const
quickOpenNavigatePreviousInTerminalPickerId
=
'
workbench.action.quickOpenNavigatePreviousInTerminalPicker
'
;
CommandsRegistry
.
registerCommand
(
quickOpenNavigatePreviousInTerminalPickerId
,
{
handler
:
getQuickNavigateHandler
(
quickOpenNavigatePreviousInTerminalPickerId
,
false
)
});
{
id
:
quickOpenNavigatePreviousInTerminalPickerId
,
handler
:
getQuickNavigateHandler
(
quickOpenNavigatePreviousInTerminalPickerId
,
false
)
});
const
registry
=
<
IWorkbenchActionRegistry
>
Registry
.
as
(
ActionExtensions
.
WorkbenchActions
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录