Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b4ff0736
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,发现更多精彩内容 >>
提交
b4ff0736
编写于
1月 27, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
💄
上级
5c6b51aa
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
5 deletion
+34
-5
src/vs/platform/actions/common/actions.ts
src/vs/platform/actions/common/actions.ts
+34
-5
未找到文件。
src/vs/platform/actions/common/actions.ts
浏览文件 @
b4ff0736
...
...
@@ -8,7 +8,7 @@ import { SyncDescriptor0, createSyncDescriptor } from 'vs/platform/instantiation
import
{
IConstructorSignature2
,
createDecorator
,
BrandedService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindings
,
KeybindingsRegistry
,
IKeybindingRule
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
ContextKeyExpr
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ICommandService
,
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICommandService
,
CommandsRegistry
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IDisposable
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
...
...
@@ -351,9 +351,27 @@ export class SyncActionDescriptor {
type
OneOrN
<
T
>
=
T
|
T
[];
export
interface
IAction2Options
extends
ICommandAction
{
/**
* Shorthand to add this command to the command palette
*/
f1
?:
boolean
;
/**
* One or many menu items.
*/
menu
?:
OneOrN
<
{
id
:
MenuId
}
&
Omit
<
IMenuItem
,
'
command
'
>>
;
keybinding
?:
Omit
<
IKeybindingRule
,
'
id
'
>
;
/**
* One keybinding.
*/
keybinding
?:
OneOrN
<
Omit
<
IKeybindingRule
,
'
id
'
>>
;
/**
* Metadata about this command, used for API commands or when
* showing keybindings that have no other UX.
*/
description
?:
ICommandHandlerDescription
;
}
export
abstract
class
Action2
{
...
...
@@ -364,12 +382,15 @@ export abstract class Action2 {
export
function
registerAction2
(
ctor
:
{
new
():
Action2
}):
IDisposable
{
const
disposables
=
new
DisposableStore
();
const
action
=
new
ctor
();
// command
disposables
.
add
(
CommandsRegistry
.
registerCommand
({
id
:
action
.
desc
.
id
,
handler
:
(
accessor
,
...
args
)
=>
action
.
run
(
accessor
,
...
args
),
description
:
undefined
,
description
:
action
.
desc
.
description
,
}));
// menu
if
(
Array
.
isArray
(
action
.
desc
.
menu
))
{
for
(
let
item
of
action
.
desc
.
menu
)
{
disposables
.
add
(
MenuRegistry
.
appendMenuItem
(
item
.
id
,
{
command
:
action
.
desc
,
...
item
}));
...
...
@@ -377,12 +398,20 @@ export function registerAction2(ctor: { new(): Action2 }): IDisposable {
}
else
if
(
action
.
desc
.
menu
)
{
disposables
.
add
(
MenuRegistry
.
appendMenuItem
(
action
.
desc
.
menu
.
id
,
{
command
:
action
.
desc
,
...
action
.
desc
.
menu
}));
}
if
(
action
.
desc
.
f1
)
{
disposables
.
add
(
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
{
command
:
action
.
desc
,
...
action
.
desc
}));
}
if
(
action
.
desc
.
keybinding
)
{
// keybinding
if
(
Array
.
isArray
(
action
.
desc
.
keybinding
))
{
for
(
let
item
of
action
.
desc
.
keybinding
)
{
KeybindingsRegistry
.
registerKeybindingRule
({
...
item
,
id
:
action
.
desc
.
id
,
when
:
ContextKeyExpr
.
and
(
action
.
desc
.
precondition
,
item
.
when
)
});
}
}
else
if
(
action
.
desc
.
keybinding
)
{
KeybindingsRegistry
.
registerKeybindingRule
({
...
action
.
desc
.
keybinding
,
id
:
action
.
desc
.
id
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录