Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
66f4bf35
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
66f4bf35
编写于
11月 28, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - manually set command arg when getting menu actions
上级
41b09433
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
55 addition
and
73 deletion
+55
-73
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
+1
-1
src/vs/platform/actions/browser/menuItemActionItem.ts
src/vs/platform/actions/browser/menuItemActionItem.ts
+13
-17
src/vs/platform/actions/common/actions.ts
src/vs/platform/actions/common/actions.ts
+26
-41
src/vs/platform/actions/common/menuService.ts
src/vs/platform/actions/common/menuService.ts
+9
-8
src/vs/platform/actions/test/common/menuService.test.ts
src/vs/platform/actions/test/common/menuService.test.ts
+1
-1
src/vs/workbench/browser/parts/editor/titleControl.ts
src/vs/workbench/browser/parts/editor/titleControl.ts
+2
-2
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
+2
-2
src/vs/workbench/parts/markers/browser/markersTreeController.ts
.../workbench/parts/markers/browser/markersTreeController.ts
+1
-1
未找到文件。
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
浏览文件 @
66f4bf35
...
...
@@ -127,7 +127,7 @@ export class ContextMenuController implements IEditorContribution {
const
result
:
IAction
[]
=
[];
let
contextMenu
=
this
.
_menuService
.
createMenu
(
MenuId
.
EditorContext
,
this
.
_contextKeyService
);
const
groups
=
contextMenu
.
getActions
();
const
groups
=
contextMenu
.
getActions
(
this
.
_editor
.
getModel
().
uri
);
contextMenu
.
dispose
();
for
(
let
group
of
groups
)
{
...
...
src/vs/platform/actions/browser/menuItemActionItem.ts
浏览文件 @
66f4bf35
...
...
@@ -17,8 +17,8 @@ import { domEvent } from 'vs/base/browser/event';
import
{
Emitter
}
from
'
vs/base/common/event
'
;
export
function
fillInActions
(
menu
:
IMenu
,
target
:
IAction
[]
|
{
primary
:
IAction
[];
secondary
:
IAction
[];
}):
void
{
const
groups
=
menu
.
getActions
();
export
function
fillInActions
(
menu
:
IMenu
,
context
:
any
,
target
:
IAction
[]
|
{
primary
:
IAction
[];
secondary
:
IAction
[];
}):
void
{
const
groups
=
menu
.
getActions
(
context
);
if
(
groups
.
length
===
0
)
{
return
;
}
...
...
@@ -98,21 +98,18 @@ class MenuItemActionItem extends ActionItem {
@
IKeybindingService
private
_keybindingService
:
IKeybindingService
,
@
IMessageService
private
_messageService
:
IMessageService
)
{
super
(
undefined
,
action
,
{
icon
:
!!
action
.
c
ommand
.
iconClass
,
label
:
!
action
.
command
.
iconC
lass
});
super
(
undefined
,
action
,
{
icon
:
!!
action
.
c
lass
,
label
:
!
action
.
c
lass
});
}
private
get
_command
()
{
const
{
command
,
altCommand
}
=
<
MenuItemAction
>
this
.
_action
;
return
this
.
_wantsAltCommand
&&
altCommand
||
command
;
return
this
.
_wantsAltCommand
&&
(
<
MenuItemAction
>
this
.
_action
).
alt
||
this
.
_action
;
}
onClick
(
event
:
MouseEvent
):
void
{
event
.
preventDefault
();
event
.
stopPropagation
();
(
<
MenuItemAction
>
this
.
_action
).
run
(
this
.
_wantsAltCommand
).
done
(
undefined
,
err
=>
{
this
.
_messageService
.
show
(
Severity
.
Error
,
err
);
});
this
.
_command
.
run
().
done
(
undefined
,
err
=>
this
.
_messageService
.
show
(
Severity
.
Error
,
err
));
}
render
(
container
:
HTMLElement
):
void
{
...
...
@@ -149,7 +146,7 @@ class MenuItemActionItem extends ActionItem {
_updateLabel
():
void
{
if
(
this
.
options
.
label
)
{
this
.
$e
.
text
(
this
.
_command
.
title
);
this
.
$e
.
text
(
this
.
_command
.
label
);
}
}
...
...
@@ -159,20 +156,19 @@ class MenuItemActionItem extends ActionItem {
const
keybindingLabel
=
keybinding
&&
this
.
_keybindingService
.
getLabelFor
(
keybinding
);
element
.
title
=
keybindingLabel
?
localize
(
'
titleAndKb
'
,
"
{0} ({1})
"
,
this
.
_command
.
title
,
keybindingLabel
)
:
this
.
_command
.
title
;
?
localize
(
'
titleAndKb
'
,
"
{0} ({1})
"
,
this
.
_command
.
label
,
keybindingLabel
)
:
this
.
_command
.
label
;
}
_updateClass
():
void
{
if
(
this
.
options
.
icon
)
{
const
element
=
this
.
$e
.
getHTMLElement
();
const
{
command
,
altCommand
}
=
(
<
MenuItemAction
>
this
.
_action
);
if
(
this
.
_command
!==
command
)
{
element
.
classList
.
remove
(
command
.
iconClass
);
}
else
if
(
altCommand
)
{
element
.
classList
.
remove
(
altCommand
.
iconClass
);
if
(
this
.
_command
!==
this
.
_action
)
{
element
.
classList
.
remove
(
this
.
_action
.
class
);
}
else
if
((
<
MenuItemAction
>
this
.
_action
).
alt
)
{
element
.
classList
.
remove
((
<
MenuItemAction
>
this
.
_action
).
alt
.
class
);
}
element
.
classList
.
add
(
'
icon
'
,
this
.
_command
.
iconC
lass
);
element
.
classList
.
add
(
'
icon
'
,
this
.
_command
.
c
lass
);
}
}
}
src/vs/platform/actions/common/actions.ts
浏览文件 @
66f4bf35
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IAction
,
Action
}
from
'
vs/base/common/actions
'
;
import
{
Promise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
SyncDescriptor0
,
createSyncDescriptor
,
AsyncDescriptor0
}
from
'
vs/platform/instantiation/common/descriptors
'
;
...
...
@@ -24,7 +23,7 @@ export interface ICommandAction {
export
interface
IMenu
extends
IDisposable
{
onDidChange
:
Event
<
IMenu
>
;
getActions
(
):
[
string
,
I
Action
[]][];
getActions
(
arg
?:
any
):
[
string
,
MenuItem
Action
[]][];
}
export
interface
IMenuItem
{
...
...
@@ -100,59 +99,45 @@ export const MenuRegistry: IMenuRegistry = new class {
}
};
export
class
MenuItemAction
extends
Action
{
private
static
_getMenuItemId
(
item
:
IMenuItem
):
string
{
let
result
=
item
.
command
.
id
;
if
(
item
.
alt
)
{
result
+=
`||
${
item
.
alt
.
id
}
`
;
}
return
result
;
}
export
class
ExecuteCommandAction
extends
Action
{
constructor
(
private
_item
:
IMenuItem
,
@
ICommandService
private
_commandService
:
ICommandService
,
@
IContextKeyService
private
_contextKeyService
:
IContextKeyService
)
{
super
(
MenuItemAction
.
_getMenuItemId
(
_item
),
_item
.
command
.
title
);
this
.
order
=
this
.
_item
.
order
;
//TODO@Ben order is menu item property, not an action property
}
get
item
():
IMenuItem
{
return
this
.
_item
;
}
get
command
()
{
return
this
.
_item
.
command
;
}
id
:
string
,
label
:
string
,
@
ICommandService
private
_commandService
:
ICommandService
)
{
get
altCommand
()
{
return
this
.
_item
.
alt
;
super
(
id
,
label
);
}
run
(
alt
:
boolean
)
{
const
{
id
}
=
alt
===
true
&&
this
.
_item
.
alt
||
this
.
_item
.
command
;
const
resource
=
this
.
_contextKeyService
.
getContextKeyValue
<
URI
>
(
'
resource
'
);
return
this
.
_commandService
.
executeCommand
(
id
,
resource
);
run
(...
args
:
any
[]):
TPromise
<
any
>
{
return
this
.
_commandService
.
executeCommand
(
this
.
id
,
...
args
);
}
}
export
class
MenuItemAction
extends
ExecuteCommandAction
{
export
class
ExecuteCommandAction
extends
Action
{
private
_arg
:
any
;
readonly
item
:
ICommandAction
;
readonly
alt
:
MenuItemAction
;
constructor
(
id
:
string
,
label
:
string
,
@
ICommandService
private
_commandService
:
ICommandService
)
{
item
:
ICommandAction
,
alt
:
ICommandAction
,
arg
:
any
,
@
ICommandService
commandService
:
ICommandService
)
{
super
(
item
.
id
,
item
.
title
,
commandService
);
this
.
_cssClass
=
item
.
iconClass
;
this
.
_enabled
=
true
;
this
.
_arg
=
arg
;
super
(
id
,
label
);
this
.
item
=
item
;
this
.
alt
=
alt
?
new
MenuItemAction
(
alt
,
undefined
,
arg
,
commandService
)
:
undefined
;
}
run
(
...
args
:
any
[]
):
TPromise
<
any
>
{
return
this
.
_commandService
.
executeCommand
(
this
.
id
,
...
args
);
run
():
TPromise
<
any
>
{
return
super
.
run
(
this
.
_arg
);
}
}
...
...
src/vs/platform/actions/common/menuService.ts
浏览文件 @
66f4bf35
...
...
@@ -7,7 +7,6 @@
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
values
}
from
'
vs/base/common/collections
'
;
import
{
ContextKeyExpr
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
MenuId
,
MenuRegistry
,
ICommandAction
,
MenuItemAction
,
IMenu
,
IMenuItem
,
IMenuService
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -34,7 +33,7 @@ export class MenuService implements IMenuService {
}
}
type
MenuItemGroup
=
[
string
,
MenuItemAction
[]];
type
MenuItemGroup
=
[
string
,
IMenuItem
[]];
class
Menu
implements
IMenu
{
...
...
@@ -63,7 +62,7 @@ class Menu implements IMenu {
group
=
[
groupName
,
[]];
this
.
_menuGroups
.
push
(
group
);
}
group
[
1
].
push
(
new
MenuItemAction
(
item
,
this
.
_commandService
,
this
.
_contextKeyService
)
);
group
[
1
].
push
(
item
);
// keep keys for eventing
Menu
.
_fillInKbExprKeys
(
item
.
when
,
keysFilter
);
...
...
@@ -92,13 +91,15 @@ class Menu implements IMenu {
return
this
.
_onDidChange
.
event
;
}
getActions
(
):
[
string
,
I
Action
[]][]
{
const
result
:
MenuItemGroup
[]
=
[];
getActions
(
arg
?:
any
):
[
string
,
MenuItem
Action
[]][]
{
const
result
:
[
string
,
MenuItemAction
[]]
[]
=
[];
for
(
let
group
of
this
.
_menuGroups
)
{
const
[
id
,
action
s
]
=
group
;
const
[
id
,
item
s
]
=
group
;
const
activeActions
:
MenuItemAction
[]
=
[];
for
(
let
action
of
actions
)
{
if
(
this
.
_contextKeyService
.
contextMatchesRules
(
action
.
item
.
when
))
{
for
(
const
item
of
items
)
{
if
(
this
.
_contextKeyService
.
contextMatchesRules
(
item
.
when
))
{
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/platform/actions/test/common/menuService.test.ts
浏览文件 @
66f4bf35
...
...
@@ -186,4 +186,4 @@ suite('MenuService', function () {
assert
.
equal
(
two
.
id
,
'
b
'
);
assert
.
equal
(
three
.
id
,
'
a
'
);
});
});
\ No newline at end of file
});
src/vs/workbench/browser/parts/editor/titleControl.ts
浏览文件 @
66f4bf35
...
...
@@ -332,7 +332,7 @@ export abstract class TitleControl implements ITitleAreaControl {
const
titleBarMenu
=
this
.
menuService
.
createMenu
(
MenuId
.
EditorTitle
,
scopedContextKeyService
);
this
.
disposeOnEditorActions
.
push
(
titleBarMenu
,
titleBarMenu
.
onDidChange
(
_
=>
this
.
update
()));
fillInActions
(
titleBarMenu
,
{
primary
,
secondary
});
fillInActions
(
titleBarMenu
,
this
.
resourceContext
.
get
(),
{
primary
,
secondary
});
}
return
{
primary
,
secondary
};
...
...
@@ -480,7 +480,7 @@ export abstract class TitleControl implements ITitleAreaControl {
}
// Fill in contributed actions
fillInActions
(
this
.
contextMenu
,
actions
);
fillInActions
(
this
.
contextMenu
,
this
.
resourceContext
.
get
(),
actions
);
return
actions
;
}
...
...
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
浏览文件 @
66f4bf35
...
...
@@ -507,7 +507,7 @@ export class FileController extends DefaultController {
getAnchor
:
()
=>
anchor
,
getActions
:
()
=>
{
return
this
.
state
.
actionProvider
.
getSecondaryActions
(
tree
,
stat
).
then
(
actions
=>
{
fillInActions
(
this
.
contributedContextMenu
,
actions
);
fillInActions
(
this
.
contributedContextMenu
,
stat
.
resource
,
actions
);
return
actions
;
});
},
...
...
@@ -959,4 +959,4 @@ export class FileDragAndDrop implements IDragAndDrop {
promise
.
done
(
null
,
errors
.
onUnexpectedError
);
}
}
\ No newline at end of file
}
src/vs/workbench/parts/markers/browser/markersTreeController.ts
浏览文件 @
66f4bf35
...
...
@@ -156,4 +156,4 @@ export class Controller extends treedefaults.DefaultController {
}
return
null
;
}
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录