Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a98afa69
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,发现更多精彩内容 >>
提交
a98afa69
编写于
2月 15, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
menu - move custom label logic to where it is used
上级
542e4bf0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
21 deletion
+17
-21
src/vs/platform/actions/common/actions.ts
src/vs/platform/actions/common/actions.ts
+2
-3
src/vs/platform/actions/common/menu.ts
src/vs/platform/actions/common/menu.ts
+1
-8
src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
+14
-10
未找到文件。
src/vs/platform/actions/common/actions.ts
浏览文件 @
a98afa69
...
...
@@ -161,18 +161,17 @@ export class MenuItemAction extends ExecuteCommandAction {
constructor
(
item
:
ICommandAction
,
label
:
string
,
alt
:
ICommandAction
,
arg
:
any
,
@
ICommandService
commandService
:
ICommandService
)
{
super
(
item
.
id
,
label
,
commandService
);
super
(
item
.
id
,
item
.
title
,
commandService
);
this
.
_cssClass
=
item
.
iconClass
;
this
.
_enabled
=
true
;
this
.
_arg
=
arg
;
this
.
item
=
item
;
this
.
alt
=
alt
?
new
MenuItemAction
(
alt
,
alt
.
title
,
undefined
,
arg
,
commandService
)
:
undefined
;
this
.
alt
=
alt
?
new
MenuItemAction
(
alt
,
undefined
,
arg
,
commandService
)
:
undefined
;
}
run
():
TPromise
<
any
>
{
...
...
src/vs/platform/actions/common/menu.ts
浏览文件 @
a98afa69
...
...
@@ -8,7 +8,6 @@
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
ContextKeyExpr
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
MenuId
,
MenuRegistry
,
MenuItemAction
,
IMenu
,
IMenuItem
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
...
...
@@ -77,13 +76,7 @@ export class Menu implements IMenu {
const
activeActions
:
MenuItemAction
[]
=
[];
for
(
const
item
of
items
)
{
if
(
this
.
_contextKeyService
.
contextMatchesRules
(
item
.
when
))
{
let
title
=
item
.
command
.
title
;
if
(
this
.
id
===
MenuId
.
CommandPalette
&&
item
.
command
.
category
)
{
title
=
localize
(
''
,
"
{0}: {1}
"
,
item
.
command
.
category
,
title
);
}
const
action
=
new
MenuItemAction
(
item
.
command
,
title
,
item
.
alt
,
arg
,
this
.
_commandService
);
const
action
=
new
MenuItemAction
(
item
.
command
,
item
.
alt
,
arg
,
this
.
_commandService
);
action
.
order
=
item
.
order
;
//TODO@Ben order is menu item property, not an action property
activeActions
.
push
(
action
);
}
...
...
src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
浏览文件 @
a98afa69
...
...
@@ -16,7 +16,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
{
Mode
,
IEntryRunContext
,
IAutoFocus
}
from
'
vs/base/parts/quickopen/common/quickOpen
'
;
import
{
QuickOpenEntryGroup
,
IHighlight
,
QuickOpenModel
,
QuickOpenEntry
}
from
'
vs/base/parts/quickopen/browser/quickOpenModel
'
;
import
{
SyncActionDescriptor
,
IMenuService
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
SyncActionDescriptor
,
IMenuService
,
MenuId
,
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
...
...
@@ -277,8 +277,8 @@ export class CommandsHandler extends QuickOpenHandler {
// Other Actions
const
menu
=
this
.
menuService
.
createMenu
(
MenuId
.
CommandPalette
,
this
.
contextKeyService
);
const
menuActions
=
menu
.
getActions
().
reduce
((
r
,
[,
actions
])
=>
[...
r
,
...
actions
],
[]);
const
commandEntries
=
this
.
command
ActionsToEntries
(
menuActions
,
searchValue
);
const
menuActions
=
menu
.
getActions
().
reduce
((
r
,
[,
actions
])
=>
[...
r
,
...
actions
],
<
MenuItemAction
[]
>
[]);
const
commandEntries
=
this
.
menuItem
ActionsToEntries
(
menuActions
,
searchValue
);
// Concat
let
entries
=
[...
workbenchEntries
,
...
editorEntries
,
...
commandEntries
];
...
...
@@ -355,17 +355,21 @@ export class CommandsHandler extends QuickOpenHandler {
return
entries
;
}
private
commandActionsToEntries
(
actions
:
I
Action
[],
searchValue
:
string
):
ActionCommandEntry
[]
{
private
menuItemActionsToEntries
(
actions
:
MenuItem
Action
[],
searchValue
:
string
):
ActionCommandEntry
[]
{
const
entries
:
ActionCommandEntry
[]
=
[];
for
(
let
action
of
actions
)
{
const
[
keybind
]
=
this
.
keybindingService
.
lookupKeybindings
(
action
.
id
);
const
label
=
action
.
item
.
category
?
nls
.
localize
(
'
cat.title
'
,
"
{0}: {1}
"
,
action
.
item
.
category
,
action
.
item
.
title
)
:
action
.
item
.
title
;
const
highlights
=
wordFilter
(
searchValue
,
label
);
if
(
!
highlights
)
{
continue
;
}
const
[
keybind
]
=
this
.
keybindingService
.
lookupKeybindings
(
action
.
item
.
id
);
const
keyLabel
=
keybind
?
this
.
keybindingService
.
getLabelFor
(
keybind
)
:
''
;
const
keyAriaLabel
=
keybind
?
this
.
keybindingService
.
getAriaLabelFor
(
keybind
)
:
''
;
const
highlights
=
wordFilter
(
searchValue
,
action
.
label
);
if
(
highlights
)
{
entries
.
push
(
this
.
instantiationService
.
createInstance
(
ActionCommandEntry
,
keyLabel
,
keyAriaLabel
,
action
.
label
,
null
,
highlights
,
null
,
action
));
}
entries
.
push
(
this
.
instantiationService
.
createInstance
(
ActionCommandEntry
,
keyLabel
,
keyAriaLabel
,
label
,
null
,
highlights
,
null
,
action
));
}
return
entries
;
...
...
@@ -398,4 +402,4 @@ export class EditorCommandsHandler extends CommandsHandler {
protected
includeWorkbenchCommands
():
boolean
{
return
false
;
}
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录