Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
8899a0cb
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,发现更多精彩内容 >>
提交
8899a0cb
编写于
12月 17, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
explorer: introduce ExplorerService
上级
39b480b6
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
119 addition
and
124 deletion
+119
-124
src/vs/workbench/parts/files/browser/files.ts
src/vs/workbench/parts/files/browser/files.ts
+2
-1
src/vs/workbench/parts/files/common/explorerService.ts
src/vs/workbench/parts/files/common/explorerService.ts
+10
-47
src/vs/workbench/parts/files/common/files.ts
src/vs/workbench/parts/files/common/files.ts
+59
-28
src/vs/workbench/parts/files/electron-browser/fileActions.ts
src/vs/workbench/parts/files/electron-browser/fileActions.ts
+7
-5
src/vs/workbench/parts/files/electron-browser/files.contribution.ts
...kbench/parts/files/electron-browser/files.contribution.ts
+5
-1
src/vs/workbench/parts/files/electron-browser/views/explorerDecorationsProvider.ts
...les/electron-browser/views/explorerDecorationsProvider.ts
+3
-3
src/vs/workbench/parts/files/electron-browser/views/explorerView.ts
...kbench/parts/files/electron-browser/views/explorerView.ts
+24
-30
src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
...ench/parts/files/electron-browser/views/explorerViewer.ts
+7
-6
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
...nch/parts/files/electron-browser/views/openEditorsView.ts
+1
-2
src/vs/workbench/parts/files/test/electron-browser/explorerService.test.ts
...parts/files/test/electron-browser/explorerService.test.ts
+1
-1
未找到文件。
src/vs/workbench/parts/files/browser/files.ts
浏览文件 @
8899a0cb
...
...
@@ -5,7 +5,8 @@
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
ExplorerItem
,
OpenEditor
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
ExplorerItem
}
from
'
vs/workbench/parts/files/common/explorerService
'
;
import
{
OpenEditor
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
List
}
from
'
vs/base/browser/ui/list/listWidget
'
;
...
...
src/vs/workbench/parts/files/common/explorer
Model
.ts
→
src/vs/workbench/parts/files/common/explorer
Service
.ts
浏览文件 @
8899a0cb
...
...
@@ -4,20 +4,26 @@
*--------------------------------------------------------------------------------------------*/
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
IFileStat
}
from
'
vs/platform/files/common/files
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
toResource
,
IEditorIdentifier
,
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
rtrim
,
startsWithIgnoreCase
,
startsWith
,
equalsIgnoreCase
}
from
'
vs/base/common/strings
'
;
import
{
IEditorGroup
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
IExplorerService
}
from
'
vs/workbench/parts/files/common/files
'
;
export
class
Model
{
export
class
ExplorerService
implements
IExplorerService
{
_serviceBrand
:
any
;
setEditable
(
stat
:
ExplorerItem
,
editable
:
boolean
):
void
{
throw
new
Error
(
'
Method not implemented.
'
);
}
onDidEditStat
:
Event
<
ExplorerItem
>
;
private
_roots
:
ExplorerItem
[];
private
_listener
:
IDisposable
;
...
...
@@ -450,46 +456,3 @@ export class NewStatPlaceholder extends ExplorerItem {
return
child
;
}
}
export
class
OpenEditor
implements
IEditorIdentifier
{
constructor
(
private
_editor
:
IEditorInput
,
private
_group
:
IEditorGroup
)
{
// noop
}
public
get
editor
()
{
return
this
.
_editor
;
}
public
get
editorIndex
()
{
return
this
.
_group
.
getIndexOfEditor
(
this
.
editor
);
}
public
get
group
()
{
return
this
.
_group
;
}
public
get
groupId
()
{
return
this
.
_group
.
id
;
}
public
getId
():
string
{
return
`openeditor:
${
this
.
groupId
}
:
${
this
.
editorIndex
}
:
${
this
.
editor
.
getName
()}
:
${
this
.
editor
.
getDescription
()}
`
;
}
public
isPreview
():
boolean
{
return
this
.
_group
.
previewEditor
===
this
.
editor
;
}
public
isUntitled
():
boolean
{
return
!!
toResource
(
this
.
editor
,
{
supportSideBySide
:
true
,
filter
:
Schemas
.
untitled
});
}
public
isDirty
():
boolean
{
return
this
.
editor
.
isDirty
();
}
public
getResource
():
URI
|
null
{
return
toResource
(
this
.
editor
,
{
supportSideBySide
:
true
});
}
}
src/vs/workbench/parts/files/common/files.ts
浏览文件 @
8899a0cb
...
...
@@ -5,13 +5,13 @@
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IWorkbenchEditorConfiguration
}
from
'
vs/workbench/common/editor
'
;
import
{
IWorkbenchEditorConfiguration
,
IEditorIdentifier
,
IEditorInput
,
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
IFilesConfiguration
,
FileChangeType
,
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
ExplorerItem
,
OpenEditor
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
ContextKeyExpr
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ITextModelContentProvider
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
,
ILanguageSelection
}
from
'
vs/editor/common/services/modeService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
...
...
@@ -20,6 +20,9 @@ import { InputFocusedContextKey } from 'vs/platform/workbench/common/contextkeys
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
ViewContainer
}
from
'
vs/workbench/common/views
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ExplorerItem
}
from
'
vs/workbench/parts/files/common/explorerService
'
;
import
{
IEditorGroup
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
/**
* Explorer viewlet id.
...
...
@@ -38,6 +41,17 @@ export interface IExplorerView {
select
(
resource
:
URI
,
reveal
?:
boolean
):
void
;
}
export
interface
IExplorerService
{
_serviceBrand
:
any
;
readonly
roots
:
ExplorerItem
[];
readonly
onDidEditStat
:
Event
<
ExplorerItem
>
;
setEditable
(
stat
:
ExplorerItem
,
editable
:
boolean
):
void
;
findClosest
(
resource
:
URI
):
ExplorerItem
|
null
;
findAll
(
resource
:
URI
):
ExplorerItem
[];
}
export
const
IExplorerService
=
createDecorator
<
IExplorerService
>
(
'
explorerService
'
);
/**
* Context Keys to use with keybindings for the Explorer and Open Editors view
*/
...
...
@@ -107,32 +121,6 @@ export interface IFileResource {
isDirectory
?:
boolean
;
}
/**
* Helper to get an explorer item from an object.
*/
export
function
explorerItemToFileResource
(
obj
:
ExplorerItem
|
OpenEditor
):
IFileResource
|
null
{
if
(
obj
instanceof
ExplorerItem
)
{
const
stat
=
obj
as
ExplorerItem
;
return
{
resource
:
stat
.
resource
,
isDirectory
:
stat
.
isDirectory
};
}
if
(
obj
instanceof
OpenEditor
)
{
const
editor
=
obj
as
OpenEditor
;
const
resource
=
editor
.
getResource
();
if
(
resource
)
{
return
{
resource
};
}
}
return
null
;
}
export
const
SortOrderConfiguration
=
{
DEFAULT
:
'
default
'
,
MIXED
:
'
mixed
'
,
...
...
@@ -210,3 +198,46 @@ export class FileOnDiskContentProvider implements ITextModelContentProvider {
this
.
fileWatcher
=
dispose
(
this
.
fileWatcher
);
}
}
export
class
OpenEditor
implements
IEditorIdentifier
{
constructor
(
private
_editor
:
IEditorInput
,
private
_group
:
IEditorGroup
)
{
// noop
}
public
get
editor
()
{
return
this
.
_editor
;
}
public
get
editorIndex
()
{
return
this
.
_group
.
getIndexOfEditor
(
this
.
editor
);
}
public
get
group
()
{
return
this
.
_group
;
}
public
get
groupId
()
{
return
this
.
_group
.
id
;
}
public
getId
():
string
{
return
`openeditor:
${
this
.
groupId
}
:
${
this
.
editorIndex
}
:
${
this
.
editor
.
getName
()}
:
${
this
.
editor
.
getDescription
()}
`
;
}
public
isPreview
():
boolean
{
return
this
.
_group
.
previewEditor
===
this
.
editor
;
}
public
isUntitled
():
boolean
{
return
!!
toResource
(
this
.
editor
,
{
supportSideBySide
:
true
,
filter
:
Schemas
.
untitled
});
}
public
isDirty
():
boolean
{
return
this
.
editor
.
isDirty
();
}
public
getResource
():
URI
|
null
{
return
toResource
(
this
.
editor
,
{
supportSideBySide
:
true
});
}
}
src/vs/workbench/parts/files/electron-browser/fileActions.ts
浏览文件 @
8899a0cb
...
...
@@ -21,7 +21,6 @@ import { VIEWLET_ID } from 'vs/workbench/parts/files/common/files';
import
{
ITextFileService
,
ITextFileOperationResult
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IFileService
,
IFileStat
,
AutoSaveConfiguration
}
from
'
vs/platform/files/common/files
'
;
import
{
toResource
,
IUntitledResourceInput
}
from
'
vs/workbench/common/editor
'
;
import
{
ExplorerItem
,
Model
,
NewStatPlaceholder
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
ExplorerView
}
from
'
vs/workbench/parts/files/electron-browser/views/explorerView
'
;
import
{
ExplorerViewlet
}
from
'
vs/workbench/parts/files/electron-browser/explorerViewlet
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
...
...
@@ -49,6 +48,7 @@ import { IViewlet } from 'vs/workbench/common/viewlet';
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
AsyncDataTree
}
from
'
vs/base/browser/ui/tree/asyncDataTree
'
;
import
{
EditableExplorerItems
}
from
'
vs/workbench/parts/files/electron-browser/views/explorerViewer
'
;
import
{
NewStatPlaceholder
,
ExplorerItem
}
from
'
vs/workbench/parts/files/common/explorerService
'
;
export
interface
IEditableData
{
action
:
IAction
;
...
...
@@ -767,8 +767,9 @@ export class AddFilesAction extends BaseFileAction {
if
(
this
.
element
)
{
targetElement
=
this
.
element
;
}
else
{
const
input
:
ExplorerItem
|
Model
=
this
.
tree
.
getInput
();
targetElement
=
this
.
tree
.
getFocus
()
||
(
input
instanceof
Model
?
input
.
roots
[
0
]
:
input
);
// TODO@isidor
// const input: ExplorerItem | Model = this.tree.getInput();
// targetElement = this.tree.getFocus() || (input instanceof Model ? input.roots[0] : input);
}
if
(
!
targetElement
.
isDirectory
)
{
...
...
@@ -903,8 +904,9 @@ class PasteFileAction extends BaseFileAction {
this
.
tree
=
tree
;
this
.
element
=
element
;
if
(
!
this
.
element
)
{
const
input
:
ExplorerItem
|
Model
=
this
.
tree
.
getInput
();
this
.
element
=
input
instanceof
Model
?
input
.
roots
[
0
]
:
input
;
// TODO@isidor
// const input: ExplorerItem | Model = this.tree.getInput();
// this.element = input instanceof Model ? input.roots[0] : input;
}
this
.
_updateEnablement
();
}
...
...
src/vs/workbench/parts/files/electron-browser/files.contribution.ts
浏览文件 @
8899a0cb
...
...
@@ -13,7 +13,7 @@ import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/wor
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
,
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IEditorInputFactory
,
EditorInput
,
IFileEditorInput
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
}
from
'
vs/workbench/common/editor
'
;
import
{
AutoSaveConfiguration
,
HotExitConfiguration
,
SUPPORTED_ENCODINGS
}
from
'
vs/platform/files/common/files
'
;
import
{
VIEWLET_ID
,
SortOrderConfiguration
,
FILE_EDITOR_INPUT_ID
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
VIEWLET_ID
,
SortOrderConfiguration
,
FILE_EDITOR_INPUT_ID
,
IExplorerService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
FileEditorTracker
}
from
'
vs/workbench/parts/files/browser/editors/fileEditorTracker
'
;
import
{
SaveErrorHandler
}
from
'
vs/workbench/parts/files/electron-browser/saveErrorHandler
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
...
...
@@ -35,6 +35,8 @@ import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorG
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
nativeSep
}
from
'
vs/base/common/paths
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
ExplorerService
}
from
'
vs/workbench/parts/files/common/explorerService
'
;
// Viewlet Action
export
class
OpenExplorerViewletAction
extends
ShowViewletAction
{
...
...
@@ -79,6 +81,8 @@ Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new Vie
0
));
registerSingleton
(
IExplorerService
,
ExplorerService
);
Registry
.
as
<
ViewletRegistry
>
(
ViewletExtensions
.
Viewlets
).
setDefaultViewletId
(
VIEWLET_ID
);
const
openViewletKb
:
IKeybindings
=
{
...
...
src/vs/workbench/parts/files/electron-browser/views/explorerDecorationsProvider.ts
浏览文件 @
8899a0cb
...
...
@@ -6,12 +6,12 @@
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
Model
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IDecorationsProvider
,
IDecorationData
}
from
'
vs/workbench/services/decorations/browser/decorations
'
;
import
{
listInvalidItemForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
IDisposable
}
from
'
vscode-xterm
'
;
import
{
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IExplorerService
}
from
'
vs/workbench/parts/files/common/files
'
;
export
class
ExplorerDecorationsProvider
implements
IDecorationsProvider
{
readonly
label
:
string
=
localize
(
'
label
'
,
"
Explorer
"
);
...
...
@@ -19,7 +19,7 @@ export class ExplorerDecorationsProvider implements IDecorationsProvider {
private
toDispose
:
IDisposable
[];
constructor
(
private
model
:
Model
,
@
IExplorerService
private
explorerService
:
IExplorerService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
)
{
this
.
toDispose
=
[];
...
...
@@ -37,7 +37,7 @@ export class ExplorerDecorationsProvider implements IDecorationsProvider {
}
provideDecorations
(
resource
:
URI
):
IDecorationData
|
undefined
{
const
fileStat
=
this
.
model
.
findClosest
(
resource
);
const
fileStat
=
this
.
explorerService
.
findClosest
(
resource
);
if
(
fileStat
&&
fileStat
.
isRoot
&&
fileStat
.
isError
)
{
return
{
tooltip
:
localize
(
'
canNotResolve
'
,
"
Can not resolve workspace folder
"
),
...
...
src/vs/workbench/parts/files/electron-browser/views/explorerView.ts
浏览文件 @
8899a0cb
...
...
@@ -12,7 +12,7 @@ import * as resources from 'vs/base/common/resources';
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
Action
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
{
IFilesConfiguration
,
ExplorerFolderContext
,
FilesExplorerFocusedContext
,
ExplorerFocusedContext
,
SortOrderConfiguration
,
SortOrder
,
IExplorerView
,
ExplorerRootContext
,
ExplorerResourceReadonlyContext
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFilesConfiguration
,
ExplorerFolderContext
,
FilesExplorerFocusedContext
,
ExplorerFocusedContext
,
SortOrderConfiguration
,
SortOrder
,
IExplorerView
,
ExplorerRootContext
,
ExplorerResourceReadonlyContext
,
IExplorerService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
FileOperation
,
FileOperationEvent
,
IResolveFileOptions
,
FileChangeType
,
FileChangesEvent
,
IFileService
,
FILES_EXCLUDE_CONFIG
,
IFileStat
}
from
'
vs/platform/files/common/files
'
;
import
{
RefreshViewExplorerAction
,
NewFolderAction
,
NewFileAction
,
FileCopiedContext
}
from
'
vs/workbench/parts/files/electron-browser/fileActions
'
;
import
{
toResource
}
from
'
vs/workbench/common/editor
'
;
...
...
@@ -20,7 +20,6 @@ import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
import
{
CollapseAction2
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
IViewletViewOptions
}
from
'
vs/workbench/browser/parts/views/viewsViewlet
'
;
import
{
ExplorerItem
,
Model
,
NewStatPlaceholder
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
ExplorerDecorationsProvider
}
from
'
vs/workbench/parts/files/electron-browser/views/explorerDecorationsProvider
'
;
import
{
IWorkspaceContextService
,
WorkbenchState
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
...
...
@@ -49,6 +48,7 @@ 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
,
NewStatPlaceholder
}
from
'
vs/workbench/parts/files/common/explorerService
'
;
export
interface
IExplorerViewOptions
extends
IViewletViewOptions
{
fileViewletState
:
EditableExplorerItems
;
...
...
@@ -105,7 +105,8 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
@
IListService
private
listService
:
IListService
,
@
IMenuService
private
menuService
:
IMenuService
,
@
IClipboardService
private
clipboardService
:
IClipboardService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IExplorerService
private
explorerService
:
IExplorerService
)
{
super
({
...(
options
as
IViewletPanelOptions
),
id
:
ExplorerView
.
ID
,
ariaHeaderLabel
:
nls
.
localize
(
'
explorerSection
'
,
"
Files Explorer Section
"
)
},
keybindingService
,
contextMenuService
,
configurationService
);
...
...
@@ -118,7 +119,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
this
.
readonlyContext
=
ExplorerResourceReadonlyContext
.
bindTo
(
contextKeyService
);
this
.
rootContext
=
ExplorerRootContext
.
bindTo
(
contextKeyService
);
this
.
decorationProvider
=
new
ExplorerDecorationsProvider
(
this
.
model
,
contextService
);
this
.
decorationProvider
=
new
ExplorerDecorationsProvider
(
this
.
explorerService
,
contextService
);
decorationService
.
registerDecorationsProvider
(
this
.
decorationProvider
);
this
.
disposables
.
push
(
this
.
decorationProvider
);
this
.
disposables
.
push
(
this
.
resourceContext
);
...
...
@@ -185,13 +186,6 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
return
FileCopiedContext
.
bindTo
(
this
.
contextKeyService
);
}
@
memoize
private
get
model
():
Model
{
const
model
=
this
.
instantiationService
.
createInstance
(
Model
);
this
.
disposables
.
push
(
model
);
return
model
;
}
// Split view methods
render
():
void
{
...
...
@@ -383,7 +377,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
this
.
disposables
.
push
(
filesRenderer
);
this
.
tree
=
new
WorkbenchAsyncDataTree
(
container
,
new
ExplorerDelegate
(),
[
filesRenderer
],
this
.
instantiationService
.
createInstance
(
ExplorerDataSource
,
this
.
model
),
{
this
.
instantiationService
.
createInstance
(
ExplorerDataSource
),
{
accessibilityProvider
:
new
ExplorerAccessibilityProvider
(),
ariaLabel
:
nls
.
localize
(
'
treeAriaLabel
'
,
"
Files Explorer
"
),
identityProvider
:
{
...
...
@@ -491,7 +485,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
if
(
e
.
operation
===
FileOperation
.
CREATE
||
e
.
operation
===
FileOperation
.
COPY
)
{
const
addedElement
=
e
.
target
;
const
parentResource
=
resources
.
dirname
(
addedElement
.
resource
);
const
parents
=
this
.
model
.
findAll
(
parentResource
);
const
parents
=
this
.
explorerService
.
findAll
(
parentResource
);
if
(
parents
.
length
)
{
...
...
@@ -539,7 +533,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
let
isExpanded
=
false
;
// Handle Rename
if
(
oldParentResource
&&
newParentResource
&&
oldParentResource
.
toString
()
===
newParentResource
.
toString
())
{
const
modelElements
=
this
.
model
.
findAll
(
oldResource
);
const
modelElements
=
this
.
explorerService
.
findAll
(
oldResource
);
modelElements
.
forEach
(
modelElement
=>
{
//Check if element is expanded
isExpanded
=
!
this
.
tree
.
isCollapsed
(
modelElement
);
...
...
@@ -563,8 +557,8 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
// Handle Move
else
if
(
oldParentResource
&&
newParentResource
)
{
const
newParents
=
this
.
model
.
findAll
(
newParentResource
);
const
modelElements
=
this
.
model
.
findAll
(
oldResource
);
const
newParents
=
this
.
explorerService
.
findAll
(
newParentResource
);
const
modelElements
=
this
.
explorerService
.
findAll
(
oldResource
);
if
(
newParents
.
length
&&
modelElements
.
length
)
{
...
...
@@ -585,7 +579,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
// Delete
else
if
(
e
.
operation
===
FileOperation
.
DELETE
)
{
const
modelElements
=
this
.
model
.
findAll
(
e
.
resource
);
const
modelElements
=
this
.
explorerService
.
findAll
(
e
.
resource
);
modelElements
.
forEach
(
element
=>
{
if
(
element
.
parent
)
{
const
parent
=
element
.
parent
;
...
...
@@ -643,8 +637,8 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
}
// Compute if parent is visible and added file not yet part of it
const
parentStat
=
this
.
model
.
findClosest
(
parent
);
if
(
parentStat
&&
parentStat
.
isDirectoryResolved
&&
!
this
.
model
.
findClosest
(
change
.
resource
))
{
const
parentStat
=
this
.
explorerService
.
findClosest
(
parent
);
if
(
parentStat
&&
parentStat
.
isDirectoryResolved
&&
!
this
.
explorerService
.
findClosest
(
change
.
resource
))
{
return
true
;
}
...
...
@@ -663,7 +657,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
for
(
let
j
=
0
;
j
<
deleted
.
length
;
j
++
)
{
const
del
=
deleted
[
j
];
if
(
this
.
model
.
findClosest
(
del
.
resource
))
{
if
(
this
.
explorerService
.
findClosest
(
del
.
resource
))
{
return
true
;
}
}
...
...
@@ -677,7 +671,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
for
(
let
j
=
0
;
j
<
updated
.
length
;
j
++
)
{
const
upd
=
updated
[
j
];
if
(
this
.
model
.
findClosest
(
upd
.
resource
))
{
if
(
this
.
explorerService
.
findClosest
(
upd
.
resource
))
{
return
true
;
}
}
...
...
@@ -709,7 +703,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
this
.
explorerRefreshDelayer
.
trigger
(()
=>
{
return
this
.
doRefresh
().
then
(()
=>
{
if
(
newRoots
.
length
===
1
)
{
return
this
.
tree
.
reveal
(
this
.
model
.
findClosest
(
newRoots
[
0
].
uri
),
0.5
);
return
this
.
tree
.
reveal
(
this
.
explorerService
.
findClosest
(
newRoots
[
0
].
uri
),
0.5
);
}
return
undefined
;
...
...
@@ -783,7 +777,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
}
private
doRefresh
():
Promise
<
any
>
{
const
targetsToResolve
=
this
.
model
.
roots
.
map
(
root
=>
({
root
,
resource
:
root
.
resource
,
options
:
{
resolveTo
:
[]
}
}));
const
targetsToResolve
=
this
.
explorerService
.
roots
.
map
(
root
=>
({
root
,
resource
:
root
.
resource
,
options
:
{
resolveTo
:
[]
}
}));
// First time refresh: Receive target through active editor input or selection and also include settings from previous session
if
(
!
this
.
isCreated
)
{
...
...
@@ -843,8 +837,8 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
});
// Subsequent refresh: Merge stat into our local model and refresh tree
modelStats
.
forEach
((
modelStat
,
index
)
=>
{
if
(
index
<
this
.
model
.
roots
.
length
)
{
ExplorerItem
.
mergeLocalWithDisk
(
modelStat
,
this
.
model
.
roots
[
index
]);
if
(
index
<
this
.
explorerService
.
roots
.
length
)
{
ExplorerItem
.
mergeLocalWithDisk
(
modelStat
,
this
.
explorerService
.
roots
[
index
]);
}
});
...
...
@@ -857,8 +851,8 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
.
then
(
result
=>
result
.
isDirectory
?
ExplorerItem
.
create
(
result
,
target
.
root
,
target
.
options
.
resolveTo
)
:
errorRoot
(
target
.
resource
,
target
.
root
),
()
=>
errorRoot
(
target
.
resource
,
target
.
root
))
.
then
(
modelStat
=>
{
// Subsequent refresh: Merge stat into our local model and refresh tree
if
(
index
<
this
.
model
.
roots
.
length
)
{
ExplorerItem
.
mergeLocalWithDisk
(
modelStat
,
this
.
model
.
roots
[
index
]);
if
(
index
<
this
.
explorerService
.
roots
.
length
)
{
ExplorerItem
.
mergeLocalWithDisk
(
modelStat
,
this
.
explorerService
.
roots
[
index
]);
}
return
this
.
tree
.
refresh
(
null
);
...
...
@@ -916,7 +910,7 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
return
;
}
const
fileStat
=
this
.
model
.
findClosest
(
resource
);
const
fileStat
=
this
.
explorerService
.
findClosest
(
resource
);
if
(
fileStat
)
{
this
.
doSelect
(
fileStat
,
reveal
);
return
;
...
...
@@ -925,11 +919,11 @@ export class ExplorerView extends ViewletPanel implements IExplorerView {
// Stat needs to be resolved first and then revealed
const
options
:
IResolveFileOptions
=
{
resolveTo
:
[
resource
]
};
const
workspaceFolder
=
this
.
contextService
.
getWorkspaceFolder
(
resource
);
const
rootUri
=
workspaceFolder
?
workspaceFolder
.
uri
:
this
.
model
.
roots
[
0
].
resource
;
const
rootUri
=
workspaceFolder
?
workspaceFolder
.
uri
:
this
.
explorerService
.
roots
[
0
].
resource
;
this
.
fileService
.
resolveFile
(
rootUri
,
options
).
then
(
stat
=>
{
// Convert to model
const
root
=
this
.
model
.
roots
.
filter
(
r
=>
r
.
resource
.
toString
()
===
rootUri
.
toString
()).
pop
();
const
root
=
this
.
explorerService
.
roots
.
filter
(
r
=>
r
.
resource
.
toString
()
===
rootUri
.
toString
()).
pop
();
const
modelStat
=
ExplorerItem
.
create
(
stat
,
root
,
options
.
resolveTo
);
// Update Input with disk Stat
ExplorerItem
.
mergeLocalWithDisk
(
modelStat
,
root
);
...
...
src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
浏览文件 @
8899a0cb
...
...
@@ -6,7 +6,6 @@
import
{
IAccessibilityProvider
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
ExplorerItem
,
Model
,
NewStatPlaceholder
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
...
...
@@ -22,7 +21,7 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IFilesConfiguration
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFilesConfiguration
,
IExplorerService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
dirname
,
joinPath
,
basename
}
from
'
vs/base/common/resources
'
;
import
{
InputBox
,
MessageType
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
localize
}
from
'
vs/nls
'
;
...
...
@@ -33,6 +32,7 @@ import { normalize, join, nativeSep } from 'vs/base/common/paths';
import
{
rtrim
}
from
'
vs/base/common/strings
'
;
import
{
equals
,
deepClone
}
from
'
vs/base/common/objects
'
;
import
*
as
path
from
'
path
'
;
import
{
ExplorerItem
,
NewStatPlaceholder
}
from
'
vs/workbench/parts/files/common/explorerService
'
;
export
class
ExplorerDelegate
implements
IListVirtualDelegate
<
ExplorerItem
>
{
...
...
@@ -50,7 +50,7 @@ export class ExplorerDelegate implements IListVirtualDelegate<ExplorerItem> {
export
class
ExplorerDataSource
implements
IDataSource
<
ExplorerItem
>
{
constructor
(
private
model
:
Model
,
@
IExplorerService
private
explorerService
:
IExplorerService
,
@
IProgressService
private
progressService
:
IProgressService
,
@
INotificationService
private
notificationService
:
INotificationService
,
@
IFileService
private
fileService
:
IFileService
,
...
...
@@ -64,11 +64,12 @@ export class ExplorerDataSource implements IDataSource<ExplorerItem> {
getChildren
(
element
:
ExplorerItem
|
null
):
Promise
<
ExplorerItem
[]
>
{
if
(
element
===
null
)
{
if
(
this
.
contextService
.
getWorkbenchState
()
!==
WorkbenchState
.
FOLDER
||
this
.
model
.
roots
[
0
].
isError
)
{
const
roots
=
this
.
explorerService
.
roots
;
if
(
this
.
contextService
.
getWorkbenchState
()
!==
WorkbenchState
.
FOLDER
||
roots
[
0
].
isError
)
{
// Display roots only when multi folder workspace
return
Promise
.
resolve
(
this
.
model
.
roots
);
return
Promise
.
resolve
(
roots
);
}
element
=
this
.
model
.
roots
[
0
];
element
=
roots
[
0
];
}
// Return early if stat is already resolved
...
...
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
浏览文件 @
8899a0cb
...
...
@@ -14,9 +14,8 @@ import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/co
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
SaveAllAction
,
SaveAllInGroupAction
,
CloseGroupAction
}
from
'
vs/workbench/parts/files/electron-browser/fileActions
'
;
import
{
OpenEditorsFocusedContext
,
ExplorerFocusedContext
,
IFilesConfiguration
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
OpenEditorsFocusedContext
,
ExplorerFocusedContext
,
IFilesConfiguration
,
OpenEditor
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
ITextFileService
,
AutoSaveMode
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
OpenEditor
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
CloseAllEditorsAction
,
CloseEditorAction
}
from
'
vs/workbench/browser/parts/editor/editorActions
'
;
import
{
ToggleEditorLayoutAction
}
from
'
vs/workbench/browser/actions/toggleEditorLayout
'
;
...
...
src/vs/workbench/parts/files/test/electron-browser/explorer
Model
.test.ts
→
src/vs/workbench/parts/files/test/electron-browser/explorer
Service
.test.ts
浏览文件 @
8899a0cb
...
...
@@ -9,7 +9,7 @@ import { isLinux, isWindows } from 'vs/base/common/platform';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
join
}
from
'
vs/base/common/paths
'
;
import
{
validateFileName
}
from
'
vs/workbench/parts/files/electron-browser/fileActions
'
;
import
{
ExplorerItem
}
from
'
vs/workbench/parts/files/common/explorer
Model
'
;
import
{
ExplorerItem
}
from
'
vs/workbench/parts/files/common/explorer
Service
'
;
function
createStat
(
path
:
string
,
name
:
string
,
isFolder
:
boolean
,
hasChildren
:
boolean
,
size
:
number
,
mtime
:
number
):
ExplorerItem
{
return
new
ExplorerItem
(
toResource
(
path
),
undefined
,
false
,
false
,
isFolder
,
name
,
mtime
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录