Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d95e22d0
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,体验更适合开发者的 AI 搜索 >>
提交
d95e22d0
编写于
1月 08, 2021
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make menubarControl prefer mnemonicTitle, make MenuItemAction only implement IAction
上级
8d8ee957
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
24 deletion
+47
-24
src/vs/platform/actions/common/actions.ts
src/vs/platform/actions/common/actions.ts
+26
-16
src/vs/workbench/browser/parts/titlebar/menubarControl.ts
src/vs/workbench/browser/parts/titlebar/menubarControl.ts
+17
-6
src/vs/workbench/electron-sandbox/parts/titlebar/menubarControl.ts
...rkbench/electron-sandbox/parts/titlebar/menubarControl.ts
+4
-2
未找到文件。
src/vs/platform/actions/common/actions.ts
浏览文件 @
d95e22d0
...
...
@@ -58,7 +58,7 @@ export interface IMenuItem {
}
export
interface
ISubmenuItem
{
title
:
string
|
I
LocalizedString
;
title
:
string
|
I
CommandActionTitle
;
submenu
:
MenuId
;
icon
?:
Icon
;
when
?:
ContextKeyExpression
;
...
...
@@ -350,44 +350,54 @@ export class SubmenuItemAction extends SubmenuAction {
}
}
export
class
MenuItemAction
extends
ExecuteCommandAction
{
// implements IAction, does NOT extend Action, so that no one
// subscribes to events of Action or modified properties
export
class
MenuItemAction
implements
IAction
{
readonly
item
:
ICommandAction
;
readonly
alt
:
MenuItemAction
|
undefined
;
private
readonly
_options
:
IMenuActionOptions
|
undefined
;
readonly
id
:
string
;
readonly
label
:
string
;
readonly
tooltip
:
string
;
readonly
class
:
string
|
undefined
;
readonly
enabled
:
boolean
;
readonly
checked
:
boolean
;
constructor
(
item
:
ICommandAction
,
alt
:
ICommandAction
|
undefined
,
options
:
IMenuActionOptions
,
options
:
IMenuActionOptions
|
undefined
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
ICommandService
commandService
:
ICommandService
@
ICommandService
private
_
commandService
:
ICommandService
)
{
t
ypeof
item
.
title
===
'
string
'
?
super
(
item
.
id
,
item
.
title
,
commandService
)
:
super
(
item
.
id
,
item
.
title
.
value
,
commandService
)
;
this
.
_cssClass
=
undefined
;
this
.
_
enabled
=
!
item
.
precondition
||
contextKeyService
.
contextMatchesRules
(
item
.
precondition
);
this
.
_tooltip
=
item
.
tooltip
;
t
his
.
id
=
item
.
id
;
this
.
label
=
typeof
item
.
title
===
'
string
'
?
item
.
title
:
item
.
title
.
value
;
this
.
tooltip
=
item
.
tooltip
??
''
;
this
.
enabled
=
!
item
.
precondition
||
contextKeyService
.
contextMatchesRules
(
item
.
precondition
);
this
.
checked
=
false
;
if
(
item
.
toggled
)
{
const
toggled
=
((
item
.
toggled
as
{
condition
:
ContextKeyExpression
}).
condition
?
item
.
toggled
:
{
condition
:
item
.
toggled
})
as
{
condition
:
ContextKeyExpression
,
icon
?:
Icon
,
tooltip
?:
string
|
ILocalizedString
};
this
.
_
checked
=
contextKeyService
.
contextMatchesRules
(
toggled
.
condition
);
if
(
this
.
_
checked
&&
toggled
.
tooltip
)
{
this
.
_
tooltip
=
typeof
toggled
.
tooltip
===
'
string
'
?
toggled
.
tooltip
:
toggled
.
tooltip
.
value
;
this
.
checked
=
contextKeyService
.
contextMatchesRules
(
toggled
.
condition
);
if
(
this
.
checked
&&
toggled
.
tooltip
)
{
this
.
tooltip
=
typeof
toggled
.
tooltip
===
'
string
'
?
toggled
.
tooltip
:
toggled
.
tooltip
.
value
;
}
}
this
.
item
=
item
;
this
.
alt
=
alt
?
new
MenuItemAction
(
alt
,
undefined
,
options
,
contextKeyService
,
commandService
)
:
undefined
;
this
.
alt
=
alt
?
new
MenuItemAction
(
alt
,
undefined
,
options
,
contextKeyService
,
_
commandService
)
:
undefined
;
this
.
_options
=
options
;
}
dispose
():
void
{
this
.
alt
?.
dispose
();
super
.
dispose
();
// there is NOTHING to dispose and the MenuItemAction should
// never have anything to dispose as it is a convenience type
// to bridge into the rendering world.
}
run
(...
args
:
any
[]):
Promise
<
any
>
{
...
...
@@ -401,7 +411,7 @@ export class MenuItemAction extends ExecuteCommandAction {
runArgs
=
[...
runArgs
,
...
args
];
}
return
super
.
run
(
...
runArgs
);
return
this
.
_commandService
.
executeCommand
(
this
.
id
,
...
runArgs
);
}
}
...
...
src/vs/workbench/browser/parts/titlebar/menubarControl.ts
浏览文件 @
d95e22d0
...
...
@@ -37,6 +37,7 @@ import { BrowserFeatures } from 'vs/base/browser/canIUse';
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IsWebContext
}
from
'
vs/platform/contextkey/common/contextkeys
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
export
abstract
class
MenubarControl
extends
Disposable
{
...
...
@@ -91,7 +92,8 @@ export abstract class MenubarControl extends Disposable {
protected
readonly
preferencesService
:
IPreferencesService
,
protected
readonly
environmentService
:
IWorkbenchEnvironmentService
,
protected
readonly
accessibilityService
:
IAccessibilityService
,
protected
readonly
hostService
:
IHostService
protected
readonly
hostService
:
IHostService
,
protected
readonly
commandService
:
ICommandService
)
{
super
();
...
...
@@ -308,9 +310,10 @@ export class CustomMenubarControl extends MenubarControl {
@
IAccessibilityService
accessibilityService
:
IAccessibilityService
,
@
IThemeService
private
readonly
themeService
:
IThemeService
,
@
IWorkbenchLayoutService
private
readonly
layoutService
:
IWorkbenchLayoutService
,
@
IHostService
protected
readonly
hostService
:
IHostService
@
IHostService
protected
readonly
hostService
:
IHostService
,
@
ICommandService
commandService
:
ICommandService
)
{
super
(
menuService
,
workspacesService
,
contextKeyService
,
keybindingService
,
configurationService
,
labelService
,
updateService
,
storageService
,
notificationService
,
preferencesService
,
environmentService
,
accessibilityService
,
hostService
);
super
(
menuService
,
workspacesService
,
contextKeyService
,
keybindingService
,
configurationService
,
labelService
,
updateService
,
storageService
,
notificationService
,
preferencesService
,
environmentService
,
accessibilityService
,
hostService
,
commandService
);
this
.
_onVisibilityChange
=
this
.
_register
(
new
Emitter
<
boolean
>
());
this
.
_onFocusStateChange
=
this
.
_register
(
new
Emitter
<
boolean
>
());
...
...
@@ -592,6 +595,12 @@ export class CustomMenubarControl extends MenubarControl {
for
(
let
action
of
actions
)
{
this
.
insertActionsBefore
(
action
,
target
);
// use mnemonicTitle whenever possible
const
title
=
typeof
action
.
item
.
title
===
'
string
'
?
action
.
item
.
title
:
action
.
item
.
title
.
mnemonicTitle
??
action
.
item
.
title
.
value
;
if
(
action
instanceof
SubmenuItemAction
)
{
let
submenu
=
this
.
menus
[
action
.
item
.
submenu
.
id
];
if
(
!
submenu
)
{
...
...
@@ -609,10 +618,12 @@ export class CustomMenubarControl extends MenubarControl {
const
submenuActions
:
SubmenuAction
[]
=
[];
updateActions
(
submenu
,
submenuActions
,
topLevelTitle
);
target
.
push
(
new
SubmenuAction
(
action
.
id
,
mnemonicMenuLabel
(
action
.
label
),
submenuActions
));
target
.
push
(
new
SubmenuAction
(
action
.
id
,
mnemonicMenuLabel
(
title
),
submenuActions
));
}
else
{
action
.
label
=
mnemonicMenuLabel
(
this
.
calculateActionLabel
(
action
));
target
.
push
(
action
);
const
newAction
=
new
Action
(
action
.
id
,
mnemonicMenuLabel
(
title
),
action
.
class
,
action
.
enabled
,
()
=>
this
.
commandService
.
executeCommand
(
action
.
id
));
newAction
.
tooltip
=
action
.
tooltip
;
newAction
.
checked
=
action
.
checked
;
target
.
push
(
newAction
);
}
}
...
...
src/vs/workbench/electron-sandbox/parts/titlebar/menubarControl.ts
浏览文件 @
d95e22d0
...
...
@@ -25,6 +25,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
import
{
INativeHostService
}
from
'
vs/platform/native/electron-sandbox/native
'
;
import
{
IHostService
}
from
'
vs/workbench/services/host/browser/host
'
;
import
{
IPreferencesService
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
export
class
NativeMenubarControl
extends
MenubarControl
{
...
...
@@ -43,9 +44,10 @@ export class NativeMenubarControl extends MenubarControl {
@
IAccessibilityService
accessibilityService
:
IAccessibilityService
,
@
IMenubarService
private
readonly
menubarService
:
IMenubarService
,
@
IHostService
hostService
:
IHostService
,
@
INativeHostService
private
readonly
nativeHostService
:
INativeHostService
@
INativeHostService
private
readonly
nativeHostService
:
INativeHostService
,
@
ICommandService
commandService
:
ICommandService
,
)
{
super
(
menuService
,
workspacesService
,
contextKeyService
,
keybindingService
,
configurationService
,
labelService
,
updateService
,
storageService
,
notificationService
,
preferencesService
,
environmentService
,
accessibilityService
,
hostService
);
super
(
menuService
,
workspacesService
,
contextKeyService
,
keybindingService
,
configurationService
,
labelService
,
updateService
,
storageService
,
notificationService
,
preferencesService
,
environmentService
,
accessibilityService
,
hostService
,
commandService
);
if
(
isMacintosh
)
{
this
.
menus
[
'
Preferences
'
]
=
this
.
_register
(
this
.
menuService
.
createMenu
(
MenuId
.
MenubarPreferencesMenu
,
this
.
contextKeyService
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录