Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c51c77c8
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,发现更多精彩内容 >>
提交
c51c77c8
编写于
1月 05, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
explorer: only pass uri as a context
fixes #41157
上级
6b8d750a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
58 deletion
+27
-58
src/vs/workbench/parts/files/electron-browser/fileActions.ts
src/vs/workbench/parts/files/electron-browser/fileActions.ts
+25
-46
src/vs/workbench/parts/files/electron-browser/views/explorerView.ts
...kbench/parts/files/electron-browser/views/explorerView.ts
+1
-1
src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
...ench/parts/files/electron-browser/views/explorerViewer.ts
+1
-11
未找到文件。
src/vs/workbench/parts/files/electron-browser/fileActions.ts
浏览文件 @
c51c77c8
...
...
@@ -8,7 +8,7 @@
import
'
vs/css!./media/fileactions
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
isWindows
,
isLinux
,
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
isWindows
,
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
sequence
,
ITask
,
always
}
from
'
vs/base/common/async
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
resources
=
require
(
'
vs/base/common/resources
'
);
...
...
@@ -51,19 +51,12 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
ICommandService
,
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IListService
,
ListWidget
}
from
'
vs/platform/list/browser/listService
'
;
import
{
RawContextKey
,
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IEvent
}
from
'
vs/platform/contextview/browser/contextView
'
;
export
interface
IEditableData
{
action
:
IAction
;
validator
:
IInputValidator
;
}
export
interface
IExplorerContext
{
viewletState
:
IFileViewletState
;
event
?:
IEvent
;
stat
:
FileStat
;
}
export
interface
IFileViewletState
{
getEditableData
(
stat
:
IFileStat
):
IEditableData
;
setEditable
(
stat
:
IFileStat
,
editableData
:
IEditableData
):
void
;
...
...
@@ -662,18 +655,6 @@ class BaseDeleteFileAction extends BaseFileAction {
this
.
tree
.
clearHighlight
();
}
// Read context
if
(
context
)
{
if
(
context
.
event
)
{
const
bypassTrash
=
(
isMacintosh
&&
context
.
event
.
altKey
)
||
(
!
isMacintosh
&&
context
.
event
.
shiftKey
);
if
(
bypassTrash
)
{
this
.
useTrash
=
false
;
}
}
else
if
(
typeof
context
.
useTrash
===
'
boolean
'
)
{
this
.
useTrash
=
context
.
useTrash
;
}
}
let
primaryButton
:
string
;
if
(
this
.
useTrash
)
{
primaryButton
=
isWindows
?
nls
.
localize
(
'
deleteButtonLabelRecycleBin
'
,
"
&&Move to Recycle Bin
"
)
:
nls
.
localize
({
key
:
'
deleteButtonLabelTrash
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
&&Move to Trash
"
);
...
...
@@ -1549,13 +1530,24 @@ if (!diag) {
});
}
interface
IExplorerContext
{
viewletState
:
IFileViewletState
;
stat
:
FileStat
;
}
function
getContext
(
tree
:
ListWidget
,
viewletService
:
IViewletService
):
IExplorerContext
{
// These commands can only be triggered when explorer viewlet is visible so get it using the active viewlet
return
{
stat
:
tree
.
getFocus
(),
viewletState
:
(
<
ExplorerViewlet
>
viewletService
.
getActiveViewlet
()).
getViewletState
()
};
}
// TODO@isidor these commands are calling into actions due to the complex inheritance action structure.
// It should be the other way around, that actions call into commands.
CommandsRegistry
.
registerCommand
({
id
:
NEW_FILE_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
,
explorerContext
:
IExplorerContext
)
=>
{
handler
:
(
accessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
const
newFileAction
=
instantationService
.
createInstance
(
NewFileAction
,
listService
.
lastFocusedList
,
explorerContext
.
stat
);
return
newFileAction
.
run
(
explorerContext
);
...
...
@@ -1564,69 +1556,56 @@ CommandsRegistry.registerCommand({
CommandsRegistry
.
registerCommand
({
id
:
NEW_FOLDER_COMMAND_ID
,
handler
:
(
accessor
,
resource
:
URI
,
explorerContext
:
IExplorerContext
)
=>
{
handler
:
(
accessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
const
newFolderAction
=
instantationService
.
createInstance
(
NewFolderAction
,
listService
.
lastFocusedList
,
explorerContext
.
stat
);
return
newFolderAction
.
run
(
explorerContext
);
}
});
function
getContext
(
tree
:
ListWidget
,
viewletService
:
IViewletService
):
IExplorerContext
{
return
{
stat
:
tree
.
getFocus
(),
viewletState
:
(
<
ExplorerViewlet
>
viewletService
.
getActiveViewlet
()).
getViewletState
()
};
}
export
const
renameHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
explorerContext
:
IExplorerContext
)
=>
{
export
const
renameHandler
=
(
accessor
:
ServicesAccessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
explorerContext
)
{
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
const
renameAction
=
instantationService
.
createInstance
(
TriggerRenameFileAction
,
listService
.
lastFocusedList
,
explorerContext
.
stat
);
return
renameAction
.
run
(
explorerContext
);
};
export
const
moveFileToTrashHandler
=
(
accessor
,
resource
:
URI
,
explorerContext
:
IExplorerContext
)
=>
{
export
const
moveFileToTrashHandler
=
(
accessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
explorerContext
)
{
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
const
moveFileToTrashAction
=
instantationService
.
createInstance
(
BaseDeleteFileAction
,
listService
.
lastFocusedList
,
explorerContext
.
stat
,
true
);
return
moveFileToTrashAction
.
run
(
explorerContext
);
};
export
const
deleteFileHandler
=
(
accessor
,
resource
:
URI
,
explorerContext
:
IExplorerContext
)
=>
{
export
const
deleteFileHandler
=
(
accessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
explorerContext
)
{
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
const
deleteFileAction
=
instantationService
.
createInstance
(
BaseDeleteFileAction
,
listService
.
lastFocusedList
,
explorerContext
.
stat
,
false
);
return
deleteFileAction
.
run
(
explorerContext
);
};
export
const
copyFileHandler
=
(
accessor
,
resource
:
URI
,
explorerContext
:
IExplorerContext
)
=>
{
export
const
copyFileHandler
=
(
accessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
explorerContext
)
{
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
const
copyFileAction
=
instantationService
.
createInstance
(
CopyFileAction
,
listService
.
lastFocusedList
,
explorerContext
.
stat
);
return
copyFileAction
.
run
();
};
export
const
pasteFileHandler
=
(
accessor
,
resource
:
URI
,
explorerContext
:
IExplorerContext
)
=>
{
export
const
pasteFileHandler
=
(
accessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
explorerContext
)
{
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
,
accessor
.
get
(
IViewletService
));
const
pasteFileAction
=
instantationService
.
createInstance
(
PasteFileAction
,
listService
.
lastFocusedList
,
explorerContext
.
stat
);
return
pasteFileAction
.
run
();
...
...
src/vs/workbench/parts/files/electron-browser/views/explorerView.ts
浏览文件 @
c51c77c8
...
...
@@ -395,7 +395,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
public
createViewer
(
container
:
Builder
):
WorkbenchTree
{
const
dataSource
=
this
.
instantiationService
.
createInstance
(
FileDataSource
);
const
renderer
=
this
.
instantiationService
.
createInstance
(
FileRenderer
,
this
.
viewletState
);
const
controller
=
this
.
instantiationService
.
createInstance
(
FileController
,
this
.
viewletState
);
const
controller
=
this
.
instantiationService
.
createInstance
(
FileController
);
this
.
disposables
.
push
(
controller
);
const
sorter
=
this
.
instantiationService
.
createInstance
(
FileSorter
);
this
.
disposables
.
push
(
sorter
);
...
...
src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
浏览文件 @
c51c77c8
...
...
@@ -327,13 +327,11 @@ export class FileAccessibilityProvider implements IAccessibilityProvider {
// Explorer Controller
export
class
FileController
extends
DefaultController
implements
IDisposable
{
private
state
:
FileViewletState
;
private
contributedContextMenu
:
IMenu
;
private
toDispose
:
IDisposable
[];
constructor
(
state
:
FileViewletState
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
constructor
(
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IMenuService
menuService
:
IMenuService
,
...
...
@@ -345,7 +343,6 @@ export class FileController extends DefaultController implements IDisposable {
this
.
contributedContextMenu
=
menuService
.
createMenu
(
MenuId
.
ExplorerContext
,
contextKeyService
);
this
.
toDispose
.
push
(
this
.
contributedContextMenu
);
this
.
state
=
state
;
}
public
onLeftClick
(
tree
:
ITree
,
stat
:
FileStat
|
Model
,
event
:
IMouseEvent
,
origin
:
string
=
'
mouse
'
):
boolean
{
...
...
@@ -430,13 +427,6 @@ export class FileController extends DefaultController implements IDisposable {
fillInActions
(
this
.
contributedContextMenu
,
{
arg
:
stat
instanceof
FileStat
?
stat
.
resource
:
undefined
,
shouldForwardArgs
:
true
},
actions
);
return
TPromise
.
as
(
actions
);
},
getActionsContext
:
(
event
)
=>
{
return
{
viewletState
:
this
.
state
,
stat
,
event
};
},
onHide
:
(
wasCancelled
?:
boolean
)
=>
{
if
(
wasCancelled
)
{
tree
.
DOMFocus
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录