Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2b0800a5
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,发现更多精彩内容 >>
提交
2b0800a5
编写于
7月 24, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify Command registration
上级
403a5869
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
26 deletion
+40
-26
src/vs/editor/browser/controller/coreCommands.ts
src/vs/editor/browser/controller/coreCommands.ts
+1
-1
src/vs/editor/browser/editorExtensions.ts
src/vs/editor/browser/editorExtensions.ts
+25
-11
src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts
...ench/parts/extensions/electron-browser/extensionEditor.ts
+1
-1
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
.../preferences/electron-browser/preferences.contribution.ts
+10
-10
src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts
...ch/parts/webview/electron-browser/webview.contribution.ts
+3
-3
未找到文件。
src/vs/editor/browser/controller/coreCommands.ts
浏览文件 @
2b0800a5
...
...
@@ -1620,7 +1620,7 @@ function findFocusedEditor(accessor: ServicesAccessor): ICodeEditor {
}
function
registerCommand
(
command
:
Command
)
{
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
command
.
toCommandAndKeybindingRule
(
CORE_WEIGHT
)
);
command
.
register
(
CORE_WEIGHT
);
}
/**
...
...
src/vs/editor/browser/editorExtensions.ts
浏览文件 @
2b0800a5
...
...
@@ -31,11 +31,18 @@ export interface ICommandKeybindingsOptions extends IKeybindings {
kbExpr
?:
ContextKeyExpr
;
weight
?:
number
;
}
// export interface ICommandMenubarOptions {
// group?: string;
// order?: number;
// when?: ContextKeyExpr;
// title?: string;
// }
export
interface
ICommandOptions
{
id
:
string
;
precondition
:
ContextKeyExpr
;
kbOpts
?:
ICommandKeybindingsOptions
;
description
?:
ICommandHandlerDescription
;
// menubarOpts?: ICommandMenubarOptions;
}
export
abstract
class
Command
{
public
readonly
id
:
string
;
...
...
@@ -50,7 +57,7 @@ export abstract class Command {
this
.
_description
=
opts
.
description
;
}
p
ublic
toCommandAndKeybindingRule
(
defaultWeight
:
number
):
ICommandAndKeybindingRule
{
p
rivate
_
toCommandAndKeybindingRule
(
defaultWeight
:
number
):
ICommandAndKeybindingRule
{
const
kbOpts
=
this
.
_kbOpts
||
{
primary
:
0
};
let
kbWhen
=
kbOpts
.
kbExpr
;
...
...
@@ -78,6 +85,10 @@ export abstract class Command {
};
}
public
register
(
defaultWeight
:
number
):
void
{
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
this
.
_toCommandAndKeybindingRule
(
defaultWeight
));
}
public
abstract
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
|
TPromise
<
void
>
;
}
...
...
@@ -166,7 +177,7 @@ export abstract class EditorAction extends EditorCommand {
this
.
menuOpts
=
opts
.
menuOpts
;
}
p
ublic
toMenuItem
():
IMenuItem
{
p
rivate
_
toMenuItem
():
IMenuItem
{
if
(
!
this
.
menuOpts
)
{
return
null
;
}
...
...
@@ -182,6 +193,16 @@ export abstract class EditorAction extends EditorCommand {
};
}
public
register
(
defaultWeight
:
number
):
void
{
let
menuItem
=
this
.
_toMenuItem
();
if
(
menuItem
)
{
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorContext
,
menuItem
);
}
super
.
register
(
defaultWeight
);
}
public
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
,
args
:
any
):
void
|
TPromise
<
void
>
{
this
.
reportTelemetry
(
accessor
,
editor
);
return
this
.
run
(
accessor
,
editor
,
args
||
{});
...
...
@@ -295,14 +316,7 @@ class EditorContributionRegistry {
}
public
registerEditorAction
(
action
:
EditorAction
)
{
let
menuItem
=
action
.
toMenuItem
();
if
(
menuItem
)
{
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorContext
,
menuItem
);
}
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
action
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
action
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
());
this
.
editorActions
.
push
(
action
);
}
...
...
@@ -315,7 +329,7 @@ class EditorContributionRegistry {
}
public
registerEditorCommand
(
editorCommand
:
EditorCommand
)
{
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
editorCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
editorCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
this
.
editorCommands
[
editorCommand
.
id
]
=
editorCommand
;
}
...
...
src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts
浏览文件 @
2b0800a5
...
...
@@ -1124,4 +1124,4 @@ const showCommand = new ShowExtensionEditorFindCommand({
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_F
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
showCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
showCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
浏览文件 @
2b0800a5
...
...
@@ -353,7 +353,7 @@ const startSearchCommand = new StartSearchDefaultSettingsCommand({
precondition
:
ContextKeyExpr
.
and
(
CONTEXT_SETTINGS_EDITOR
),
kbOpts
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_F
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
startSearchCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
startSearchCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
class
FocusSearchFromSettingsCommand
extends
SettingsCommand
{
...
...
@@ -369,7 +369,7 @@ const focusSearchFromSettingsCommand = new FocusSearchFromSettingsCommand({
precondition
:
ContextKeyExpr
.
and
(
CONTEXT_SETTINGS_EDITOR
,
CONTEXT_SETTINGS_FIRST_ROW_FOCUS
),
kbOpts
:
{
primary
:
KeyCode
.
UpArrow
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusSearchFromSettingsCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
()
));
focusSearchFromSettingsCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
));
class
ClearSearchResultsCommand
extends
SettingsCommand
{
...
...
@@ -386,7 +386,7 @@ const clearSearchResultsCommand = new ClearSearchResultsCommand({
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
Escape
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
clearSearchResultsCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
clearSearchResultsCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
class
FocusSettingsFileEditorCommand
extends
SettingsCommand
{
...
...
@@ -404,14 +404,14 @@ const focusSettingsFileEditorCommand = new FocusSettingsFileEditorCommand({
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
DownArrow
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusSettingsFileEditorCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
focusSettingsFileEditorCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
const
focusSettingsFromSearchCommand
=
new
FocusSettingsFileEditorCommand
({
id
:
SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
DownArrow
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusSettingsFromSearchCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
()
));
focusSettingsFromSearchCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
));
class
FocusNextSearchResultCommand
extends
SettingsCommand
{
...
...
@@ -427,7 +427,7 @@ const focusNextSearchResultCommand = new FocusNextSearchResultCommand({
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusNextSearchResultCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
focusNextSearchResultCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
class
FocusPreviousSearchResultCommand
extends
SettingsCommand
{
...
...
@@ -443,7 +443,7 @@ const focusPreviousSearchResultCommand = new FocusPreviousSearchResultCommand({
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyMod
.
Shift
|
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusPreviousSearchResultCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
focusPreviousSearchResultCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
class
EditFocusedSettingCommand
extends
SettingsCommand
{
...
...
@@ -459,7 +459,7 @@ const editFocusedSettingCommand = new EditFocusedSettingCommand({
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
US_DOT
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
editFocusedSettingCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
editFocusedSettingCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
class
EditFocusedSettingCommand2
extends
SettingsCommand
{
...
...
@@ -476,7 +476,7 @@ const editFocusedSettingCommand2 = new EditFocusedSettingCommand2({
precondition
:
ContextKeyExpr
.
and
(
CONTEXT_SETTINGS_EDITOR
,
CONTEXT_SETTINGS_ROW_FOCUS
),
kbOpts
:
{
primary
:
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
editFocusedSettingCommand2
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
()
));
editFocusedSettingCommand2
.
register
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
));
class
FocusSettingsListCommand
extends
SettingsCommand
{
...
...
@@ -493,7 +493,7 @@ const focusSettingsListCommand = new FocusSettingsListCommand({
precondition
:
ContextKeyExpr
.
and
(
CONTEXT_SETTINGS_EDITOR
,
CONTEXT_TOC_ROW_FOCUS
),
kbOpts
:
{
primary
:
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusSettingsListCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
()
));
focusSettingsListCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
));
// Preferences menu
...
...
src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts
浏览文件 @
2b0800a5
...
...
@@ -45,7 +45,7 @@ const showNextFindWdigetCommand = new ShowWebViewEditorFindWidgetCommand({
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_F
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
showNextFindWdigetCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
showNextFindWdigetCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
const
hideCommand
=
new
HideWebViewEditorFindCommand
({
id
:
HideWebViewEditorFindCommand
.
ID
,
...
...
@@ -56,7 +56,7 @@ const hideCommand = new HideWebViewEditorFindCommand({
primary
:
KeyCode
.
Escape
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
hideCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
hideCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
const
selectAllCommand
=
new
SelectAllWebviewEditorCommand
({
id
:
SelectAllWebviewEditorCommand
.
ID
,
...
...
@@ -65,7 +65,7 @@ const selectAllCommand = new SelectAllWebviewEditorCommand({
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_A
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
selectAllCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
selectAllCommand
.
register
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
));
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
OpenWebviewDeveloperToolsAction
,
OpenWebviewDeveloperToolsAction
.
ID
,
OpenWebviewDeveloperToolsAction
.
LABEL
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录