Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
77352812
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,发现更多精彩内容 >>
提交
77352812
编写于
3月 02, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commands be honest about arguments
fixes #44895
上级
ebc41052
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
30 deletion
+30
-30
src/vs/workbench/browser/parts/editor/editorCommands.ts
src/vs/workbench/browser/parts/editor/editorCommands.ts
+4
-4
src/vs/workbench/parts/files/browser/files.ts
src/vs/workbench/parts/files/browser/files.ts
+3
-2
src/vs/workbench/parts/files/electron-browser/fileCommands.ts
...vs/workbench/parts/files/electron-browser/fileCommands.ts
+23
-24
未找到文件。
src/vs/workbench/browser/parts/editor/editorCommands.ts
浏览文件 @
77352812
...
...
@@ -269,7 +269,7 @@ function registerEditorCommands() {
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
void
0
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyCode
.
KEY_U
),
handler
:
(
accessor
,
resource
:
URI
,
context
:
IEditorCommandsContext
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
,
context
:
IEditorCommandsContext
)
=>
{
const
editorGroupService
=
accessor
.
get
(
IEditorGroupService
);
const
model
=
editorGroupService
.
getStacksModel
();
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
...
...
@@ -299,7 +299,7 @@ function registerEditorCommands() {
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
void
0
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyCode
.
KEY_W
),
handler
:
(
accessor
,
resource
:
URI
,
context
:
IEditorCommandsContext
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
,
context
:
IEditorCommandsContext
)
=>
{
const
editorGroupService
=
accessor
.
get
(
IEditorGroupService
);
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
contexts
=
getMultiSelectedEditorContexts
(
context
,
accessor
.
get
(
IListService
));
...
...
@@ -324,7 +324,7 @@ function registerEditorCommands() {
when
:
void
0
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_W
,
win
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
F4
,
secondary
:
[
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_W
]
},
handler
:
(
accessor
,
resource
:
URI
,
context
:
IEditorCommandsContext
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
,
context
:
IEditorCommandsContext
)
=>
{
const
editorGroupService
=
accessor
.
get
(
IEditorGroupService
);
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
...
...
@@ -373,7 +373,7 @@ function registerEditorCommands() {
when
:
void
0
,
primary
:
void
0
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Alt
|
KeyCode
.
KEY_T
},
handler
:
(
accessor
,
resource
:
URI
,
context
:
IEditorCommandsContext
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
,
context
:
IEditorCommandsContext
)
=>
{
const
editorGroupService
=
accessor
.
get
(
IEditorGroupService
);
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
contexts
=
getMultiSelectedEditorContexts
(
context
,
accessor
.
get
(
IListService
));
...
...
src/vs/workbench/parts/files/browser/files.ts
浏览文件 @
77352812
...
...
@@ -16,7 +16,7 @@ import { IFileStat } from 'vs/platform/files/common/files';
// Commands can get exeucted from a command pallete, from a context menu or from some list using a keybinding
// To cover all these cases we need to properly compute the resource on which the command is being executed
export
function
getResourceForCommand
(
resource
:
URI
,
listService
:
IListService
,
editorService
:
IWorkbenchEditorService
):
URI
{
export
function
getResourceForCommand
(
resource
:
URI
|
{}
,
listService
:
IListService
,
editorService
:
IWorkbenchEditorService
):
URI
{
if
(
URI
.
isUri
(
resource
))
{
return
resource
;
}
...
...
@@ -34,7 +34,7 @@ export function getResourceForCommand(resource: URI, listService: IListService,
return
toResource
(
editorService
.
getActiveEditorInput
(),
{
supportSideBySide
:
true
});
}
export
function
getMultiSelectedResources
(
resource
:
URI
,
listService
:
IListService
,
editorService
:
IWorkbenchEditorService
):
URI
[]
{
export
function
getMultiSelectedResources
(
resource
:
URI
|
{}
,
listService
:
IListService
,
editorService
:
IWorkbenchEditorService
):
URI
[]
{
const
list
=
listService
.
lastFocusedList
;
if
(
list
&&
list
.
isDOMFocused
())
{
// Explorer
...
...
@@ -49,6 +49,7 @@ export function getMultiSelectedResources(resource: URI, listService: IListServi
}
}
}
// Open editors view
if
(
list
instanceof
List
)
{
const
focus
=
list
.
getFocusedElements
();
...
...
src/vs/workbench/parts/files/electron-browser/fileCommands.ts
浏览文件 @
77352812
...
...
@@ -240,7 +240,7 @@ function saveAll(saveAllArguments: any, editorService: IWorkbenchEditorService,
CommandsRegistry
.
registerCommand
({
id
:
REVERT_FILE_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
textFileService
=
accessor
.
get
(
ITextFileService
);
const
notificationService
=
accessor
.
get
(
INotificationService
);
...
...
@@ -264,7 +264,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
Enter
},
id
:
OPEN_TO_SIDE_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
id
:
OPEN_TO_SIDE_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
editorGroupService
=
accessor
.
get
(
IEditorGroupService
);
const
listService
=
accessor
.
get
(
IListService
);
...
...
@@ -308,7 +308,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
when
:
undefined
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyCode
.
KEY_D
),
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
if
(
!
provider
)
{
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
textModelService
=
accessor
.
get
(
ITextModelService
);
...
...
@@ -317,13 +317,13 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
resource
=
getResourceForCommand
(
resource
,
accessor
.
get
(
IListService
),
editorService
);
const
uri
=
getResourceForCommand
(
resource
,
accessor
.
get
(
IListService
),
editorService
);
if
(
resource
&&
resource
.
scheme
===
Schemas
.
file
/* only files on disk supported for now */
)
{
const
name
=
paths
.
basename
(
resource
.
fsPath
);
if
(
uri
&&
uri
.
scheme
===
Schemas
.
file
/* only files on disk supported for now */
)
{
const
name
=
paths
.
basename
(
uri
.
fsPath
);
const
editorLabel
=
nls
.
localize
(
'
modifiedLabel
'
,
"
{0} (on disk) ↔ {1}
"
,
name
,
name
);
return
editorService
.
openEditor
({
leftResource
:
URI
.
from
({
scheme
:
COMPARE_WITH_SAVED_SCHEMA
,
path
:
resource
.
fsPath
}),
rightResource
:
resource
,
label
:
editorLabel
}).
then
(()
=>
void
0
);
return
editorService
.
openEditor
({
leftResource
:
URI
.
from
({
scheme
:
COMPARE_WITH_SAVED_SCHEMA
,
path
:
uri
.
fsPath
}),
rightResource
:
resource
,
label
:
editorLabel
}).
then
(()
=>
void
0
);
}
return
TPromise
.
as
(
true
);
...
...
@@ -334,7 +334,7 @@ let globalResourceToCompare: URI;
let
resourceSelectedForCompareContext
:
IContextKey
<
boolean
>
;
CommandsRegistry
.
registerCommand
({
id
:
SELECT_FOR_COMPARE_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
listService
=
accessor
.
get
(
IListService
);
const
tree
=
listService
.
lastFocusedList
;
// Remove highlight
...
...
@@ -353,7 +353,7 @@ CommandsRegistry.registerCommand({
CommandsRegistry
.
registerCommand
({
id
:
COMPARE_SELECTED_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
resources
=
getMultiSelectedResources
(
resource
,
accessor
.
get
(
IListService
),
editorService
);
...
...
@@ -370,7 +370,7 @@ CommandsRegistry.registerCommand({
CommandsRegistry
.
registerCommand
({
id
:
COMPARE_RESOURCE_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
listService
=
accessor
.
get
(
IListService
);
const
tree
=
listService
.
lastFocusedList
;
...
...
@@ -402,7 +402,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
win
:
{
primary
:
KeyMod
.
Shift
|
KeyMod
.
Alt
|
KeyCode
.
KEY_R
},
handler
:
(
accessor
:
ServicesAccessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
:
ServicesAccessor
,
resource
:
URI
|
{}
)
=>
{
const
resources
=
getMultiSelectedResources
(
resource
,
accessor
.
get
(
IListService
),
accessor
.
get
(
IWorkbenchEditorService
));
revealResourcesInOS
(
resources
,
accessor
.
get
(
IWindowsService
),
accessor
.
get
(
INotificationService
));
}
...
...
@@ -412,7 +412,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
when
:
undefined
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyCode
.
KEY_R
),
id
:
'
workbench.action.files.revealActiveFileInWindows
'
,
handler
:
(
accessor
:
ServicesAccessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
:
ServicesAccessor
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
activeInput
=
editorService
.
getActiveEditorInput
();
const
resources
=
activeInput
&&
activeInput
.
getResource
()
?
[
activeInput
.
getResource
()]
:
[];
...
...
@@ -437,7 +437,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary
:
KeyMod
.
Shift
|
KeyMod
.
Alt
|
KeyCode
.
KEY_C
},
id
:
COPY_PATH_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
resources
=
getMultiSelectedResources
(
resource
,
accessor
.
get
(
IListService
),
accessor
.
get
(
IWorkbenchEditorService
));
resourcesToClipboard
(
resources
,
accessor
.
get
(
IClipboardService
),
accessor
.
get
(
INotificationService
));
}
...
...
@@ -448,7 +448,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
when
:
undefined
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyCode
.
KEY_P
),
id
:
'
workbench.action.files.copyPathOfActiveFile
'
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
activeInput
=
editorService
.
getActiveEditorInput
();
const
resources
=
activeInput
&&
activeInput
.
getResource
()
?
[
activeInput
.
getResource
()]
:
[];
...
...
@@ -458,18 +458,18 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
CommandsRegistry
.
registerCommand
({
id
:
REVEAL_IN_EXPLORER_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
viewletService
=
accessor
.
get
(
IViewletService
);
const
contextService
=
accessor
.
get
(
IWorkspaceContextService
);
resource
=
getResourceForCommand
(
resource
,
accessor
.
get
(
IListService
),
accessor
.
get
(
IWorkbenchEditorService
));
const
uri
=
getResourceForCommand
(
resource
,
accessor
.
get
(
IListService
),
accessor
.
get
(
IWorkbenchEditorService
));
viewletService
.
openViewlet
(
VIEWLET_ID
,
false
).
then
((
viewlet
:
ExplorerViewlet
)
=>
{
const
isInsideWorkspace
=
contextService
.
isInsideWorkspace
(
resource
);
const
isInsideWorkspace
=
contextService
.
isInsideWorkspace
(
uri
);
if
(
isInsideWorkspace
)
{
const
explorerView
=
viewlet
.
getExplorerView
();
if
(
explorerView
)
{
explorerView
.
setExpanded
(
true
);
explorerView
.
select
(
resource
,
true
);
explorerView
.
select
(
uri
,
true
);
}
}
else
{
const
openEditorsView
=
viewlet
.
getOpenEditorsView
();
...
...
@@ -486,10 +486,9 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
undefined
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
KEY_S
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
resource
=
getResourceForCommand
(
resource
,
accessor
.
get
(
IListService
),
editorService
);
return
save
(
resource
,
true
,
editorService
,
accessor
.
get
(
IFileService
),
accessor
.
get
(
IUntitledEditorService
),
accessor
.
get
(
ITextFileService
),
accessor
.
get
(
IEditorGroupService
));
return
save
(
getResourceForCommand
(
resource
,
accessor
.
get
(
IListService
),
editorService
),
true
,
editorService
,
accessor
.
get
(
IFileService
),
accessor
.
get
(
IUntitledEditorService
),
accessor
.
get
(
ITextFileService
),
accessor
.
get
(
IEditorGroupService
));
}
});
...
...
@@ -498,7 +497,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_S
,
id
:
SAVE_FILE_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
resources
=
getMultiSelectedResources
(
resource
,
accessor
.
get
(
IListService
),
editorService
);
...
...
@@ -519,7 +518,7 @@ CommandsRegistry.registerCommand({
CommandsRegistry
.
registerCommand
({
id
:
SAVE_ALL_IN_GROUP_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
,
editorContext
:
IEditorCommandsContext
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
,
editorContext
:
IEditorCommandsContext
)
=>
{
const
contexts
=
getMultiSelectedEditorContexts
(
editorContext
,
accessor
.
get
(
IListService
));
const
editorGroupService
=
accessor
.
get
(
IEditorGroupService
);
let
saveAllArg
:
any
;
...
...
@@ -552,7 +551,7 @@ CommandsRegistry.registerCommand({
CommandsRegistry
.
registerCommand
({
id
:
REMOVE_ROOT_FOLDER_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
)
=>
{
handler
:
(
accessor
,
resource
:
URI
|
{}
)
=>
{
const
workspaceEditingService
=
accessor
.
get
(
IWorkspaceEditingService
);
const
contextService
=
accessor
.
get
(
IWorkspaceContextService
);
const
workspace
=
contextService
.
getWorkspace
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录