Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b4971f37
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,发现更多精彩内容 >>
提交
b4971f37
编写于
1月 21, 2019
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
explorer: polish cut action
上级
ff822422
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
10 deletion
+48
-10
src/vs/workbench/parts/files/common/files.ts
src/vs/workbench/parts/files/common/files.ts
+3
-0
src/vs/workbench/parts/files/electron-browser/explorerService.ts
...workbench/parts/files/electron-browser/explorerService.ts
+21
-1
src/vs/workbench/parts/files/electron-browser/fileActions.ts
src/vs/workbench/parts/files/electron-browser/fileActions.ts
+6
-4
src/vs/workbench/parts/files/electron-browser/media/explorerviewlet.css
...ch/parts/files/electron-browser/media/explorerviewlet.css
+4
-0
src/vs/workbench/parts/files/electron-browser/views/explorerView.ts
...kbench/parts/files/electron-browser/views/explorerView.ts
+11
-5
src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
...ench/parts/files/electron-browser/views/explorerViewer.ts
+3
-0
未找到文件。
src/vs/workbench/parts/files/common/files.ts
浏览文件 @
b4971f37
...
...
@@ -45,11 +45,14 @@ export interface IExplorerService {
readonly
onDidChangeItem
:
Event
<
ExplorerItem
|
undefined
>
;
readonly
onDidChangeEditable
:
Event
<
ExplorerItem
>
;
readonly
onDidSelectItem
:
Event
<
{
item
?:
ExplorerItem
,
reveal
?:
boolean
}
>
;
readonly
onDidCopyItems
:
Event
<
{
items
:
ExplorerItem
[],
cut
:
boolean
,
previouslyCutItems
:
ExplorerItem
[]
}
>
;
setEditable
(
stat
:
ExplorerItem
,
data
:
IEditableData
):
void
;
getEditableData
(
stat
:
ExplorerItem
):
IEditableData
|
undefined
;
findClosest
(
resource
:
URI
):
ExplorerItem
|
null
;
refresh
():
void
;
setToCopy
(
stats
:
ExplorerItem
[],
cut
:
boolean
):
void
;
isCut
(
stat
:
ExplorerItem
):
boolean
;
/**
* Selects and reveal the file element provided by the given resource if its found in the explorer. Will try to
...
...
src/vs/workbench/parts/files/electron-browser/explorerService.ts
浏览文件 @
b4971f37
...
...
@@ -16,6 +16,7 @@ import { ResourceGlobMatcher } from 'vs/workbench/electron-browser/resources';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IConfigurationService
,
IConfigurationChangeEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IExpression
}
from
'
vs/base/common/glob
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
function
getFileEventsExcludes
(
configurationService
:
IConfigurationService
,
root
?:
URI
):
IExpression
{
const
scope
=
root
?
{
resource
:
root
}
:
undefined
;
...
...
@@ -33,15 +34,18 @@ export class ExplorerService implements IExplorerService {
private
_onDidChangeItem
=
new
Emitter
<
ExplorerItem
|
undefined
>
();
private
_onDidChangeEditable
=
new
Emitter
<
ExplorerItem
>
();
private
_onDidSelectItem
=
new
Emitter
<
{
item
?:
ExplorerItem
,
reveal
?:
boolean
}
>
();
private
_onDidCopyItems
=
new
Emitter
<
{
items
:
ExplorerItem
[],
cut
:
boolean
,
previouslyCutItems
:
ExplorerItem
[]
}
>
();
private
disposables
:
IDisposable
[]
=
[];
private
editableStats
=
new
Map
<
ExplorerItem
,
IEditableData
>
();
private
_sortOrder
:
SortOrder
;
private
cutItems
:
ExplorerItem
[];
constructor
(
@
IFileService
private
fileService
:
IFileService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IClipboardService
private
clipboardService
:
IClipboardService
)
{
}
get
roots
():
ExplorerItem
[]
{
...
...
@@ -64,6 +68,10 @@ export class ExplorerService implements IExplorerService {
return
this
.
_onDidSelectItem
.
event
;
}
get
onDidCopyItems
():
Event
<
{
items
:
ExplorerItem
[],
cut
:
boolean
,
previouslyCutItems
:
ExplorerItem
[]
}
>
{
return
this
.
_onDidCopyItems
.
event
;
}
get
sortOrder
():
SortOrder
{
return
this
.
_sortOrder
;
}
...
...
@@ -103,6 +111,18 @@ export class ExplorerService implements IExplorerService {
this
.
_onDidChangeEditable
.
fire
(
stat
);
}
setToCopy
(
items
:
ExplorerItem
[],
cut
:
boolean
):
void
{
const
previouslyCutItems
=
this
.
cutItems
;
this
.
cutItems
=
cut
?
items
:
undefined
;
this
.
clipboardService
.
writeResources
(
items
.
map
(
s
=>
s
.
resource
));
this
.
_onDidCopyItems
.
fire
({
items
,
cut
,
previouslyCutItems
});
}
isCut
(
item
:
ExplorerItem
):
boolean
{
return
this
.
cutItems
&&
this
.
cutItems
.
indexOf
(
item
)
>=
0
;
}
getEditableData
(
stat
:
ExplorerItem
):
IEditableData
|
undefined
{
return
this
.
editableStats
.
get
(
stat
);
}
...
...
src/vs/workbench/parts/files/electron-browser/fileActions.ts
浏览文件 @
b4971f37
...
...
@@ -475,6 +475,10 @@ class PasteFileAction extends BaseErrorReportingAction {
// Copy File
const
promise
=
pasteShouldMove
?
this
.
fileService
.
moveFile
(
fileToPaste
,
targetFile
)
:
this
.
fileService
.
copyFile
(
fileToPaste
,
targetFile
);
return
promise
.
then
(
stat
=>
{
if
(
pasteShouldMove
)
{
// Cut is done. Make sure to clear cut state.
this
.
explorerService
.
setToCopy
([],
false
);
}
if
(
!
stat
.
isDirectory
)
{
return
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
options
:
{
pinned
:
true
,
preserveFocus
:
true
}
});
}
...
...
@@ -1102,22 +1106,20 @@ export const deleteFileHandler = (accessor: ServicesAccessor) => {
};
export
const
copyFileHandler
=
(
accessor
:
ServicesAccessor
)
=>
{
const
clipboardService
=
accessor
.
get
(
IClipboardService
);
const
listService
=
accessor
.
get
(
IListService
);
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
);
const
explorerService
=
accessor
.
get
(
IExplorerService
);
const
stats
=
explorerContext
.
selection
.
length
>
1
?
explorerContext
.
selection
:
[
explorerContext
.
stat
];
explorerService
.
setToCopy
(
stats
,
false
);
clipboardService
.
writeResources
(
stats
.
map
(
e
=>
e
.
resource
));
pasteShouldMove
=
false
;
};
export
const
cutFileHandler
=
(
accessor
:
ServicesAccessor
)
=>
{
const
listService
=
accessor
.
get
(
IListService
);
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
);
const
clipboardService
=
accessor
.
get
(
IClipboard
Service
);
const
explorerService
=
accessor
.
get
(
IExplorer
Service
);
const
stats
=
explorerContext
.
selection
.
length
>
1
?
explorerContext
.
selection
:
[
explorerContext
.
stat
];
clipboardService
.
writeResources
(
stats
.
map
(
s
=>
s
.
resource
)
);
explorerService
.
setToCopy
(
stats
,
true
);
pasteShouldMove
=
true
;
};
...
...
src/vs/workbench/parts/files/electron-browser/media/explorerviewlet.css
浏览文件 @
b4971f37
...
...
@@ -47,6 +47,10 @@
flex
:
1
;
}
.explorer-viewlet
.explorer-item.cut
{
opacity
:
0.3
;
}
.explorer-viewlet
.explorer-item.explorer-item-edited
.label-name
{
flex
:
0
;
/* do not steal space when label is hidden because we are in edit mode */
}
...
...
src/vs/workbench/parts/files/electron-browser/views/explorerView.ts
浏览文件 @
b4971f37
...
...
@@ -37,7 +37,6 @@ import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/work
import
{
ITreeContextMenuEvent
}
from
'
vs/base/browser/ui/tree/tree
'
;
import
{
IMenuService
,
MenuId
,
IMenu
}
from
'
vs/platform/actions/common/actions
'
;
import
{
fillInContextMenuActions
}
from
'
vs/platform/actions/browser/menuItemActionItem
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ExplorerItem
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
...
...
@@ -83,7 +82,6 @@ export class ExplorerView extends ViewletPanel {
@
IThemeService
private
readonly
themeService
:
IWorkbenchThemeService
,
@
IListService
private
readonly
listService
:
IListService
,
@
IMenuService
private
readonly
menuService
:
IMenuService
,
@
IClipboardService
private
readonly
clipboardService
:
IClipboardService
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
@
IExplorerService
private
readonly
explorerService
:
IExplorerService
,
@
IStorageService
private
readonly
storageService
:
IStorageService
...
...
@@ -185,6 +183,7 @@ export class ExplorerView extends ViewletPanel {
}
}));
this
.
disposables
.
push
(
this
.
explorerService
.
onDidSelectItem
(
e
=>
this
.
onSelectItem
(
e
.
item
,
e
.
reveal
)));
this
.
disposables
.
push
(
this
.
explorerService
.
onDidCopyItems
(
e
=>
this
.
onCopyItems
(
e
.
items
,
e
.
cut
,
e
.
previouslyCutItems
)));
// Update configuration
const
configuration
=
this
.
configurationService
.
getValue
<
IFilesConfiguration
>
();
...
...
@@ -368,9 +367,6 @@ export class ExplorerView extends ViewletPanel {
private
onContextMenu
(
e
:
ITreeContextMenuEvent
<
ExplorerItem
>
):
void
{
const
stat
=
e
.
element
;
// update dynamic contexts
this
.
fileCopiedContextKey
.
set
(
this
.
clipboardService
.
hasResources
());
const
selection
=
this
.
tree
.
getSelection
();
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
e
.
anchor
,
...
...
@@ -484,6 +480,16 @@ export class ExplorerView extends ViewletPanel {
});
}
private
onCopyItems
(
stats
:
ExplorerItem
[],
cut
:
boolean
,
previousCut
:
ExplorerItem
[]):
void
{
this
.
fileCopiedContextKey
.
set
(
stats
.
length
>
0
);
if
(
previousCut
)
{
previousCut
.
forEach
(
item
=>
this
.
tree
.
refresh
(
item
));
}
if
(
cut
)
{
stats
.
forEach
(
s
=>
this
.
tree
.
refresh
(
s
));
}
}
collapseAll
():
void
{
this
.
tree
.
collapseAll
();
}
...
...
src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
浏览文件 @
b4971f37
...
...
@@ -140,6 +140,9 @@ export class FilesRenderer implements ITreeRenderer<ExplorerItem, FuzzyScore, IF
if
(
!
editableData
)
{
templateData
.
label
.
element
.
style
.
display
=
'
flex
'
;
const
extraClasses
=
[
'
explorer-item
'
];
if
(
this
.
explorerService
.
isCut
(
stat
))
{
extraClasses
.
push
(
'
cut
'
);
}
templateData
.
label
.
setFile
(
stat
.
resource
,
{
hidePath
:
true
,
fileKind
:
stat
.
isRoot
?
FileKind
.
ROOT_FOLDER
:
stat
.
isDirectory
?
FileKind
.
FOLDER
:
FileKind
.
FILE
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录