Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4acd22df
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,发现更多精彩内容 >>
提交
4acd22df
编写于
9月 13, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
let => const; less use of FileEditorInput
上级
3fc1538d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
166 addition
and
175 deletion
+166
-175
src/vs/workbench/browser/parts/editor/editorActions.ts
src/vs/workbench/browser/parts/editor/editorActions.ts
+32
-32
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+54
-54
src/vs/workbench/parts/files/browser/saveErrorHandler.ts
src/vs/workbench/parts/files/browser/saveErrorHandler.ts
+1
-2
src/vs/workbench/parts/files/browser/views/explorerView.ts
src/vs/workbench/parts/files/browser/views/explorerView.ts
+57
-58
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
+1
-3
src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts
...workbench/parts/files/common/editors/fileEditorTracker.ts
+1
-2
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+20
-24
未找到文件。
src/vs/workbench/browser/parts/editor/editorActions.ts
浏览文件 @
4acd22df
...
@@ -64,8 +64,8 @@ export class SplitEditorAction extends Action {
...
@@ -64,8 +64,8 @@ export class SplitEditorAction extends Action {
options
.
pinned
=
true
;
options
.
pinned
=
true
;
// Count editors
// Count editors
le
t
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
cons
t
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
le
t
editorCount
=
visibleEditors
.
length
;
cons
t
editorCount
=
visibleEditors
.
length
;
let
targetPosition
:
Position
;
let
targetPosition
:
Position
;
switch
(
editorCount
)
{
switch
(
editorCount
)
{
...
@@ -120,15 +120,15 @@ export class NavigateBetweenGroupsAction extends Action {
...
@@ -120,15 +120,15 @@ export class NavigateBetweenGroupsAction extends Action {
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
// Can cycle split with active editor
// Can cycle split with active editor
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
!
activeEditor
)
{
if
(
!
activeEditor
)
{
return
TPromise
.
as
(
false
);
return
TPromise
.
as
(
false
);
}
}
// Cycle to the left and use module to start at 0 again
// Cycle to the left and use module to start at 0 again
le
t
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
cons
t
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
le
t
editorCount
=
visibleEditors
.
length
;
cons
t
editorCount
=
visibleEditors
.
length
;
le
t
newIndex
=
(
activeEditor
.
position
+
1
)
%
editorCount
;
cons
t
newIndex
=
(
activeEditor
.
position
+
1
)
%
editorCount
;
this
.
editorGroupService
.
focusGroup
(
<
Position
>
newIndex
);
this
.
editorGroupService
.
focusGroup
(
<
Position
>
newIndex
);
...
@@ -154,7 +154,7 @@ export class FocusFirstGroupAction extends Action {
...
@@ -154,7 +154,7 @@ export class FocusFirstGroupAction extends Action {
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
// Find left editor and focus it
// Find left editor and focus it
le
t
editors
=
this
.
editorService
.
getVisibleEditors
();
cons
t
editors
=
this
.
editorService
.
getVisibleEditors
();
for
(
let
editor
of
editors
)
{
for
(
let
editor
of
editors
)
{
if
(
editor
.
position
===
Position
.
LEFT
)
{
if
(
editor
.
position
===
Position
.
LEFT
)
{
this
.
editorGroupService
.
focusGroup
(
Position
.
LEFT
);
this
.
editorGroupService
.
focusGroup
(
Position
.
LEFT
);
...
@@ -164,7 +164,7 @@ export class FocusFirstGroupAction extends Action {
...
@@ -164,7 +164,7 @@ export class FocusFirstGroupAction extends Action {
}
}
// Since no editor is currently opened, try to open last history entry to the target side
// Since no editor is currently opened, try to open last history entry to the target side
le
t
history
=
this
.
historyService
.
getHistory
();
cons
t
history
=
this
.
historyService
.
getHistory
();
for
(
let
input
of
history
)
{
for
(
let
input
of
history
)
{
// For now only support to open resources from history to the side
// For now only support to open resources from history to the side
...
@@ -196,10 +196,10 @@ export abstract class BaseFocusSideGroupAction extends Action {
...
@@ -196,10 +196,10 @@ export abstract class BaseFocusSideGroupAction extends Action {
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
// Require at least the reference editor to be visible
// Require at least the reference editor to be visible
le
t
editors
=
this
.
editorService
.
getVisibleEditors
();
cons
t
editors
=
this
.
editorService
.
getVisibleEditors
();
let
referenceEditor
:
IEditor
;
let
referenceEditor
:
IEditor
;
for
(
let
i
=
0
;
i
<
editors
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
editors
.
length
;
i
++
)
{
le
t
editor
=
editors
[
i
];
cons
t
editor
=
editors
[
i
];
// Target editor exists so focus it
// Target editor exists so focus it
if
(
editor
.
position
===
this
.
getTargetEditorSide
())
{
if
(
editor
.
position
===
this
.
getTargetEditorSide
())
{
...
@@ -232,7 +232,7 @@ export abstract class BaseFocusSideGroupAction extends Action {
...
@@ -232,7 +232,7 @@ export abstract class BaseFocusSideGroupAction extends Action {
// Otherwise try to find a history entry to open to the target editor side
// Otherwise try to find a history entry to open to the target editor side
else
if
(
referenceEditor
)
{
else
if
(
referenceEditor
)
{
le
t
history
=
this
.
historyService
.
getHistory
();
cons
t
history
=
this
.
historyService
.
getHistory
();
for
(
let
input
of
history
)
{
for
(
let
input
of
history
)
{
// For now only support to open files from history to the side
// For now only support to open files from history to the side
...
@@ -311,7 +311,7 @@ export class FocusPreviousGroup extends Action {
...
@@ -311,7 +311,7 @@ export class FocusPreviousGroup extends Action {
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
// Require an active editor
// Require an active editor
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
!
activeEditor
)
{
if
(
!
activeEditor
)
{
return
TPromise
.
as
(
true
);
return
TPromise
.
as
(
true
);
}
}
...
@@ -355,7 +355,7 @@ export class FocusNextGroup extends Action {
...
@@ -355,7 +355,7 @@ export class FocusNextGroup extends Action {
// Find the next position to the right to use
// Find the next position to the right to use
let
nextPosition
:
Position
;
let
nextPosition
:
Position
;
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
!
activeEditor
)
{
if
(
!
activeEditor
)
{
nextPosition
=
Position
.
LEFT
;
nextPosition
=
Position
.
LEFT
;
}
else
if
(
activeEditor
.
position
===
Position
.
LEFT
)
{
}
else
if
(
activeEditor
.
position
===
Position
.
LEFT
)
{
...
@@ -387,7 +387,7 @@ export class OpenToSideAction extends Action {
...
@@ -387,7 +387,7 @@ export class OpenToSideAction extends Action {
}
}
private
updateEnablement
():
void
{
private
updateEnablement
():
void
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
this
.
enabled
=
(
!
activeEditor
||
activeEditor
.
position
!==
Position
.
RIGHT
);
this
.
enabled
=
(
!
activeEditor
||
activeEditor
.
position
!==
Position
.
RIGHT
);
}
}
...
@@ -395,7 +395,7 @@ export class OpenToSideAction extends Action {
...
@@ -395,7 +395,7 @@ export class OpenToSideAction extends Action {
let
entry
=
toEditorQuickOpenEntry
(
context
);
let
entry
=
toEditorQuickOpenEntry
(
context
);
if
(
entry
)
{
if
(
entry
)
{
let
typedInputPromise
:
TPromise
<
EditorInput
>
;
let
typedInputPromise
:
TPromise
<
EditorInput
>
;
le
t
input
=
entry
.
getInput
();
cons
t
input
=
entry
.
getInput
();
if
(
input
instanceof
EditorInput
)
{
if
(
input
instanceof
EditorInput
)
{
typedInputPromise
=
TPromise
.
as
(
input
);
typedInputPromise
=
TPromise
.
as
(
input
);
}
else
{
}
else
{
...
@@ -413,7 +413,7 @@ export function toEditorQuickOpenEntry(element: any): IEditorQuickOpenEntry {
...
@@ -413,7 +413,7 @@ export function toEditorQuickOpenEntry(element: any): IEditorQuickOpenEntry {
// QuickOpenEntryGroup
// QuickOpenEntryGroup
if
(
element
instanceof
QuickOpenEntryGroup
)
{
if
(
element
instanceof
QuickOpenEntryGroup
)
{
le
t
group
=
<
QuickOpenEntryGroup
>
element
;
cons
t
group
=
<
QuickOpenEntryGroup
>
element
;
if
(
group
.
getEntry
())
{
if
(
group
.
getEntry
())
{
element
=
group
.
getEntry
();
element
=
group
.
getEntry
();
}
}
...
@@ -442,11 +442,11 @@ export class CloseEditorAction extends Action {
...
@@ -442,11 +442,11 @@ export class CloseEditorAction extends Action {
}
}
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
le
t
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
cons
t
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
// Close Active Editor
// Close Active Editor
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
if
(
activeEditor
)
{
return
this
.
editorService
.
closeEditor
(
activeEditor
.
position
,
activeEditor
.
input
);
return
this
.
editorService
.
closeEditor
(
activeEditor
.
position
,
activeEditor
.
input
);
}
}
...
@@ -456,7 +456,7 @@ export class CloseEditorAction extends Action {
...
@@ -456,7 +456,7 @@ export class CloseEditorAction extends Action {
if
(
!
input
)
{
if
(
!
input
)
{
// Get Top Editor at Position
// Get Top Editor at Position
le
t
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
cons
t
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
if
(
visibleEditors
[
position
])
{
if
(
visibleEditors
[
position
])
{
input
=
visibleEditors
[
position
].
input
;
input
=
visibleEditors
[
position
].
input
;
}
}
...
@@ -485,7 +485,7 @@ export class CloseLeftEditorsInGroupAction extends Action {
...
@@ -485,7 +485,7 @@ export class CloseLeftEditorsInGroupAction extends Action {
}
}
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
le
t
editor
=
getTarget
(
this
.
editorService
,
this
.
groupService
,
context
);
cons
t
editor
=
getTarget
(
this
.
editorService
,
this
.
groupService
,
context
);
if
(
editor
)
{
if
(
editor
)
{
return
this
.
editorService
.
closeEditors
(
editor
.
position
,
editor
.
input
,
Direction
.
LEFT
);
return
this
.
editorService
.
closeEditors
(
editor
.
position
,
editor
.
input
,
Direction
.
LEFT
);
}
}
...
@@ -509,7 +509,7 @@ export class CloseRightEditorsInGroupAction extends Action {
...
@@ -509,7 +509,7 @@ export class CloseRightEditorsInGroupAction extends Action {
}
}
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
le
t
editor
=
getTarget
(
this
.
editorService
,
this
.
groupService
,
context
);
cons
t
editor
=
getTarget
(
this
.
editorService
,
this
.
groupService
,
context
);
if
(
editor
)
{
if
(
editor
)
{
return
this
.
editorService
.
closeEditors
(
editor
.
position
,
editor
.
input
,
Direction
.
RIGHT
);
return
this
.
editorService
.
closeEditors
(
editor
.
position
,
editor
.
input
,
Direction
.
RIGHT
);
}
}
...
@@ -549,7 +549,7 @@ export class CloseEditorsInOtherGroupsAction extends Action {
...
@@ -549,7 +549,7 @@ export class CloseEditorsInOtherGroupsAction extends Action {
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
if
(
activeEditor
)
{
position
=
activeEditor
.
position
;
position
=
activeEditor
.
position
;
}
}
...
@@ -613,7 +613,7 @@ export class CloseEditorsInGroupAction extends Action {
...
@@ -613,7 +613,7 @@ export class CloseEditorsInGroupAction extends Action {
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
if
(
activeEditor
)
{
position
=
activeEditor
.
position
;
position
=
activeEditor
.
position
;
}
}
...
@@ -644,14 +644,14 @@ export class MoveGroupLeftAction extends Action {
...
@@ -644,14 +644,14 @@ export class MoveGroupLeftAction extends Action {
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
&&
(
activeEditor
.
position
===
Position
.
CENTER
||
activeEditor
.
position
===
Position
.
RIGHT
))
{
if
(
activeEditor
&&
(
activeEditor
.
position
===
Position
.
CENTER
||
activeEditor
.
position
===
Position
.
RIGHT
))
{
position
=
activeEditor
.
position
;
position
=
activeEditor
.
position
;
}
}
}
}
if
(
typeof
position
===
'
number
'
)
{
if
(
typeof
position
===
'
number
'
)
{
le
t
newPosition
=
(
position
===
Position
.
CENTER
)
?
Position
.
LEFT
:
Position
.
CENTER
;
cons
t
newPosition
=
(
position
===
Position
.
CENTER
)
?
Position
.
LEFT
:
Position
.
CENTER
;
// Move group
// Move group
this
.
editorGroupService
.
moveGroup
(
position
,
newPosition
);
this
.
editorGroupService
.
moveGroup
(
position
,
newPosition
);
...
@@ -678,8 +678,8 @@ export class MoveGroupRightAction extends Action {
...
@@ -678,8 +678,8 @@ export class MoveGroupRightAction extends Action {
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
let
position
=
context
?
this
.
editorGroupService
.
getStacksModel
().
positionOfGroup
(
context
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
le
t
editors
=
this
.
editorService
.
getVisibleEditors
();
cons
t
editors
=
this
.
editorService
.
getVisibleEditors
();
if
((
editors
.
length
===
2
&&
activeEditor
.
position
===
Position
.
LEFT
)
||
(
editors
.
length
===
3
&&
activeEditor
.
position
!==
Position
.
RIGHT
))
{
if
((
editors
.
length
===
2
&&
activeEditor
.
position
===
Position
.
LEFT
)
||
(
editors
.
length
===
3
&&
activeEditor
.
position
!==
Position
.
RIGHT
))
{
position
=
activeEditor
.
position
;
position
=
activeEditor
.
position
;
...
@@ -687,7 +687,7 @@ export class MoveGroupRightAction extends Action {
...
@@ -687,7 +687,7 @@ export class MoveGroupRightAction extends Action {
}
}
if
(
typeof
position
===
'
number
'
)
{
if
(
typeof
position
===
'
number
'
)
{
le
t
newPosition
=
(
position
===
Position
.
LEFT
)
?
Position
.
CENTER
:
Position
.
RIGHT
;
cons
t
newPosition
=
(
position
===
Position
.
LEFT
)
?
Position
.
CENTER
:
Position
.
RIGHT
;
// Move group
// Move group
this
.
editorGroupService
.
moveGroup
(
position
,
newPosition
);
this
.
editorGroupService
.
moveGroup
(
position
,
newPosition
);
...
@@ -769,7 +769,7 @@ export class KeepEditorAction extends Action {
...
@@ -769,7 +769,7 @@ export class KeepEditorAction extends Action {
}
}
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
le
t
target
=
getTarget
(
this
.
editorService
,
this
.
editorGroupService
,
context
);
cons
t
target
=
getTarget
(
this
.
editorService
,
this
.
editorGroupService
,
context
);
if
(
target
)
{
if
(
target
)
{
this
.
editorGroupService
.
pinEditor
(
target
.
position
,
target
.
input
);
this
.
editorGroupService
.
pinEditor
(
target
.
position
,
target
.
input
);
}
}
...
@@ -1032,7 +1032,7 @@ export class BaseQuickOpenEditorInGroupAction extends Action {
...
@@ -1032,7 +1032,7 @@ export class BaseQuickOpenEditorInGroupAction extends Action {
}
}
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
le
t
keys
=
this
.
keybindingService
.
lookupKeybindings
(
this
.
id
);
cons
t
keys
=
this
.
keybindingService
.
lookupKeybindings
(
this
.
id
);
const
stacks
=
this
.
editorGroupService
.
getStacksModel
();
const
stacks
=
this
.
editorGroupService
.
getStacksModel
();
if
(
stacks
.
activeGroup
)
{
if
(
stacks
.
activeGroup
)
{
...
@@ -1102,7 +1102,7 @@ export class OpenPreviousEditorFromHistoryAction extends Action {
...
@@ -1102,7 +1102,7 @@ export class OpenPreviousEditorFromHistoryAction extends Action {
}
}
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
le
t
keys
=
this
.
keybindingService
.
lookupKeybindings
(
this
.
id
);
cons
t
keys
=
this
.
keybindingService
.
lookupKeybindings
(
this
.
id
);
this
.
quickOpenService
.
show
(
null
,
{
quickNavigateConfiguration
:
{
keybindings
:
keys
}
});
this
.
quickOpenService
.
show
(
null
,
{
quickNavigateConfiguration
:
{
keybindings
:
keys
}
});
...
@@ -1152,7 +1152,7 @@ export class RemoveFromEditorHistoryAction extends Action {
...
@@ -1152,7 +1152,7 @@ export class RemoveFromEditorHistoryAction extends Action {
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
// Listen for next editor to open
// Listen for next editor to open
le
t
unbind
=
this
.
editorGroupService
.
onEditorOpening
(
e
=>
{
cons
t
unbind
=
this
.
editorGroupService
.
onEditorOpening
(
e
=>
{
unbind
.
dispose
();
// listen once
unbind
.
dispose
();
// listen once
e
.
prevent
();
e
.
prevent
();
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
4acd22df
...
@@ -127,7 +127,7 @@ export class BaseFileAction extends Action {
...
@@ -127,7 +127,7 @@ export class BaseFileAction extends Action {
}
}
protected
onErrorWithRetry
(
error
:
any
,
retry
:
()
=>
TPromise
<
any
>
,
extraAction
?:
Action
):
void
{
protected
onErrorWithRetry
(
error
:
any
,
retry
:
()
=>
TPromise
<
any
>
,
extraAction
?:
Action
):
void
{
le
t
actions
=
[
cons
t
actions
=
[
new
Action
(
this
.
id
,
nls
.
localize
(
'
retry
'
,
"
Retry
"
),
null
,
true
,
()
=>
retry
()),
new
Action
(
this
.
id
,
nls
.
localize
(
'
retry
'
,
"
Retry
"
),
null
,
true
,
()
=>
retry
()),
CancelAction
CancelAction
];
];
...
@@ -136,7 +136,7 @@ export class BaseFileAction extends Action {
...
@@ -136,7 +136,7 @@ export class BaseFileAction extends Action {
actions
.
unshift
(
extraAction
);
actions
.
unshift
(
extraAction
);
}
}
le
t
errorWithRetry
:
IMessageWithAction
=
{
cons
t
errorWithRetry
:
IMessageWithAction
=
{
actions
,
actions
,
message
:
toErrorMessage
(
error
,
false
)
message
:
toErrorMessage
(
error
,
false
)
};
};
...
@@ -180,12 +180,12 @@ export class TriggerRenameFileAction extends BaseFileAction {
...
@@ -180,12 +180,12 @@ export class TriggerRenameFileAction extends BaseFileAction {
return
TPromise
.
wrapError
(
'
No context provided to BaseEnableFileRenameAction.
'
);
return
TPromise
.
wrapError
(
'
No context provided to BaseEnableFileRenameAction.
'
);
}
}
le
t
viewletState
=
<
IFileViewletState
>
context
.
viewletState
;
cons
t
viewletState
=
<
IFileViewletState
>
context
.
viewletState
;
if
(
!
viewletState
)
{
if
(
!
viewletState
)
{
return
TPromise
.
wrapError
(
'
Invalid view
le
t state provided to BaseEnableFileRenameAction.
'
);
return
TPromise
.
wrapError
(
'
Invalid view
cons
t state provided to BaseEnableFileRenameAction.
'
);
}
}
le
t
stat
=
<
IFileStat
>
context
.
stat
;
cons
t
stat
=
<
IFileStat
>
context
.
stat
;
if
(
!
stat
)
{
if
(
!
stat
)
{
return
TPromise
.
wrapError
(
'
Invalid stat provided to BaseEnableFileRenameAction.
'
);
return
TPromise
.
wrapError
(
'
Invalid stat provided to BaseEnableFileRenameAction.
'
);
}
}
...
@@ -193,7 +193,7 @@ export class TriggerRenameFileAction extends BaseFileAction {
...
@@ -193,7 +193,7 @@ export class TriggerRenameFileAction extends BaseFileAction {
viewletState
.
setEditable
(
stat
,
{
viewletState
.
setEditable
(
stat
,
{
action
:
this
.
renameAction
,
action
:
this
.
renameAction
,
validator
:
(
value
)
=>
{
validator
:
(
value
)
=>
{
le
t
message
=
this
.
validateFileName
(
this
.
element
.
parent
,
value
);
cons
t
message
=
this
.
validateFileName
(
this
.
element
.
parent
,
value
);
if
(
!
message
)
{
if
(
!
message
)
{
return
null
;
return
null
;
...
@@ -210,7 +210,7 @@ export class TriggerRenameFileAction extends BaseFileAction {
...
@@ -210,7 +210,7 @@ export class TriggerRenameFileAction extends BaseFileAction {
this
.
tree
.
refresh
(
stat
,
false
).
then
(()
=>
{
this
.
tree
.
refresh
(
stat
,
false
).
then
(()
=>
{
this
.
tree
.
setHighlight
(
stat
);
this
.
tree
.
setHighlight
(
stat
);
le
t
unbind
=
this
.
tree
.
addListener2
(
CommonEventType
.
HIGHLIGHT
,
(
e
:
IHighlightEvent
)
=>
{
cons
t
unbind
=
this
.
tree
.
addListener2
(
CommonEventType
.
HIGHLIGHT
,
(
e
:
IHighlightEvent
)
=>
{
if
(
!
e
.
highlight
)
{
if
(
!
e
.
highlight
)
{
viewletState
.
clearEditable
(
stat
);
viewletState
.
clearEditable
(
stat
);
this
.
tree
.
refresh
(
stat
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
tree
.
refresh
(
stat
).
done
(
null
,
errors
.
onUnexpectedError
);
...
@@ -251,7 +251,7 @@ export abstract class BaseRenameAction extends BaseFileAction {
...
@@ -251,7 +251,7 @@ export abstract class BaseRenameAction extends BaseFileAction {
// Automatically trim whitespaces and trailing dots to produce nice file names
// Automatically trim whitespaces and trailing dots to produce nice file names
name
=
getWellFormedFileName
(
name
);
name
=
getWellFormedFileName
(
name
);
le
t
existingName
=
getWellFormedFileName
(
this
.
element
.
name
);
cons
t
existingName
=
getWellFormedFileName
(
this
.
element
.
name
);
// Return early if name is invalid or didn't change
// Return early if name is invalid or didn't change
if
(
name
===
existingName
||
this
.
validateFileName
(
this
.
element
.
parent
,
name
))
{
if
(
name
===
existingName
||
this
.
validateFileName
(
this
.
element
.
parent
,
name
))
{
...
@@ -259,7 +259,7 @@ export abstract class BaseRenameAction extends BaseFileAction {
...
@@ -259,7 +259,7 @@ export abstract class BaseRenameAction extends BaseFileAction {
}
}
// Call function and Emit Event through viewer
// Call function and Emit Event through viewer
le
t
promise
=
this
.
runAction
(
name
).
then
((
stat
:
IFileStat
)
=>
{
cons
t
promise
=
this
.
runAction
(
name
).
then
((
stat
:
IFileStat
)
=>
{
if
(
stat
)
{
if
(
stat
)
{
this
.
onSuccess
(
stat
);
this
.
onSuccess
(
stat
);
}
}
...
@@ -392,14 +392,14 @@ export class BaseNewAction extends BaseFileAction {
...
@@ -392,14 +392,14 @@ export class BaseNewAction extends BaseFileAction {
return
TPromise
.
wrapError
(
'
No context provided to BaseNewAction.
'
);
return
TPromise
.
wrapError
(
'
No context provided to BaseNewAction.
'
);
}
}
le
t
viewletState
=
<
IFileViewletState
>
context
.
viewletState
;
cons
t
viewletState
=
<
IFileViewletState
>
context
.
viewletState
;
if
(
!
viewletState
)
{
if
(
!
viewletState
)
{
return
TPromise
.
wrapError
(
'
Invalid view
le
t state provided to BaseNewAction.
'
);
return
TPromise
.
wrapError
(
'
Invalid view
cons
t state provided to BaseNewAction.
'
);
}
}
let
folder
:
FileStat
=
this
.
presetFolder
;
let
folder
:
FileStat
=
this
.
presetFolder
;
if
(
!
folder
)
{
if
(
!
folder
)
{
le
t
focus
=
<
FileStat
>
this
.
tree
.
getFocus
();
cons
t
focus
=
<
FileStat
>
this
.
tree
.
getFocus
();
if
(
focus
)
{
if
(
focus
)
{
folder
=
focus
.
isDirectory
?
focus
:
focus
.
parent
;
folder
=
focus
.
isDirectory
?
focus
:
focus
.
parent
;
}
else
{
}
else
{
...
@@ -413,14 +413,14 @@ export class BaseNewAction extends BaseFileAction {
...
@@ -413,14 +413,14 @@ export class BaseNewAction extends BaseFileAction {
return
this
.
tree
.
reveal
(
folder
,
0.5
).
then
(()
=>
{
return
this
.
tree
.
reveal
(
folder
,
0.5
).
then
(()
=>
{
return
this
.
tree
.
expand
(
folder
).
then
(()
=>
{
return
this
.
tree
.
expand
(
folder
).
then
(()
=>
{
le
t
stat
=
NewStatPlaceholder
.
addNewStatPlaceholder
(
folder
,
!
this
.
isFile
);
cons
t
stat
=
NewStatPlaceholder
.
addNewStatPlaceholder
(
folder
,
!
this
.
isFile
);
this
.
renameAction
.
element
=
stat
;
this
.
renameAction
.
element
=
stat
;
viewletState
.
setEditable
(
stat
,
{
viewletState
.
setEditable
(
stat
,
{
action
:
this
.
renameAction
,
action
:
this
.
renameAction
,
validator
:
(
value
)
=>
{
validator
:
(
value
)
=>
{
le
t
message
=
this
.
renameAction
.
validateFileName
(
folder
,
value
);
cons
t
message
=
this
.
renameAction
.
validateFileName
(
folder
,
value
);
if
(
!
message
)
{
if
(
!
message
)
{
return
null
;
return
null
;
...
@@ -439,7 +439,7 @@ export class BaseNewAction extends BaseFileAction {
...
@@ -439,7 +439,7 @@ export class BaseNewAction extends BaseFileAction {
return
this
.
tree
.
reveal
(
stat
,
0.5
).
then
(()
=>
{
return
this
.
tree
.
reveal
(
stat
,
0.5
).
then
(()
=>
{
this
.
tree
.
setHighlight
(
stat
);
this
.
tree
.
setHighlight
(
stat
);
le
t
unbind
=
this
.
tree
.
addListener2
(
CommonEventType
.
HIGHLIGHT
,
(
e
:
IHighlightEvent
)
=>
{
cons
t
unbind
=
this
.
tree
.
addListener2
(
CommonEventType
.
HIGHLIGHT
,
(
e
:
IHighlightEvent
)
=>
{
if
(
!
e
.
highlight
)
{
if
(
!
e
.
highlight
)
{
stat
.
destroy
();
stat
.
destroy
();
this
.
tree
.
refresh
(
folder
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
tree
.
refresh
(
folder
).
done
(
null
,
errors
.
onUnexpectedError
);
...
@@ -514,8 +514,8 @@ export abstract class BaseGlobalNewAction extends Action {
...
@@ -514,8 +514,8 @@ export abstract class BaseGlobalNewAction extends Action {
return
TPromise
.
timeout
(
100
).
then
(()
=>
{
// use a timeout to prevent the explorer from revealing the active file
return
TPromise
.
timeout
(
100
).
then
(()
=>
{
// use a timeout to prevent the explorer from revealing the active file
viewlet
.
focus
();
viewlet
.
focus
();
le
t
explorer
=
<
ExplorerViewlet
>
viewlet
;
cons
t
explorer
=
<
ExplorerViewlet
>
viewlet
;
le
t
explorerView
=
explorer
.
getExplorerView
();
cons
t
explorerView
=
explorer
.
getExplorerView
();
// Not having a folder opened
// Not having a folder opened
if
(
!
explorerView
)
{
if
(
!
explorerView
)
{
...
@@ -526,7 +526,7 @@ export abstract class BaseGlobalNewAction extends Action {
...
@@ -526,7 +526,7 @@ export abstract class BaseGlobalNewAction extends Action {
explorerView
.
expand
();
explorerView
.
expand
();
}
}
le
t
action
=
this
.
toDispose
=
this
.
instantiationService
.
createInstance
(
this
.
getAction
(),
explorerView
.
getViewer
(),
null
);
cons
t
action
=
this
.
toDispose
=
this
.
instantiationService
.
createInstance
(
this
.
getAction
(),
explorerView
.
getViewer
(),
null
);
return
explorer
.
getActionRunner
().
run
(
action
);
return
explorer
.
getActionRunner
().
run
(
action
);
});
});
...
@@ -562,7 +562,7 @@ export class GlobalNewUntitledFileAction extends Action {
...
@@ -562,7 +562,7 @@ export class GlobalNewUntitledFileAction extends Action {
}
}
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
le
t
input
=
this
.
untitledEditorService
.
createOrGet
();
cons
t
input
=
this
.
untitledEditorService
.
createOrGet
();
return
this
.
editorService
.
openEditor
(
input
,
{
pinned
:
true
});
// untitled are always pinned
return
this
.
editorService
.
openEditor
(
input
,
{
pinned
:
true
});
// untitled are always pinned
}
}
...
@@ -755,7 +755,7 @@ export class BaseDeleteFileAction extends BaseFileAction {
...
@@ -755,7 +755,7 @@ export class BaseDeleteFileAction extends BaseFileAction {
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
new
LocalFileChangeEvent
(
this
.
element
.
clone
(),
null
));
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
new
LocalFileChangeEvent
(
this
.
element
.
clone
(),
null
));
// Call function
// Call function
le
t
servicePromise
=
this
.
fileService
.
del
(
this
.
element
.
resource
,
this
.
useTrash
).
then
(()
=>
{
cons
t
servicePromise
=
this
.
fileService
.
del
(
this
.
element
.
resource
,
this
.
useTrash
).
then
(()
=>
{
if
(
this
.
element
.
parent
)
{
if
(
this
.
element
.
parent
)
{
this
.
tree
.
setFocus
(
this
.
element
.
parent
);
// move focus to parent
this
.
tree
.
setFocus
(
this
.
element
.
parent
);
// move focus to parent
}
}
...
@@ -770,7 +770,7 @@ export class BaseDeleteFileAction extends BaseFileAction {
...
@@ -770,7 +770,7 @@ export class BaseDeleteFileAction extends BaseFileAction {
this
.
onErrorWithRetry
(
error
,
()
=>
this
.
run
(),
extraAction
);
this
.
onErrorWithRetry
(
error
,
()
=>
this
.
run
(),
extraAction
);
// Since the delete failed, best we can do is to refresh the explorer from the root to show the current state of files.
// Since the delete failed, best we can do is to refresh the explorer from the root to show the current state of files.
le
t
event
=
new
LocalFileChangeEvent
(
new
FileStat
(
this
.
contextService
.
getWorkspace
().
resource
,
true
,
true
),
new
FileStat
(
this
.
contextService
.
getWorkspace
().
resource
,
true
,
true
));
cons
t
event
=
new
LocalFileChangeEvent
(
new
FileStat
(
this
.
contextService
.
getWorkspace
().
resource
,
true
,
true
),
new
FileStat
(
this
.
contextService
.
getWorkspace
().
resource
,
true
,
true
));
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
event
);
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
event
);
// Focus back to tree
// Focus back to tree
...
@@ -852,8 +852,8 @@ export class ImportFileAction extends BaseFileAction {
...
@@ -852,8 +852,8 @@ export class ImportFileAction extends BaseFileAction {
}
}
public
run
(
context
?:
any
):
TPromise
<
any
>
{
public
run
(
context
?:
any
):
TPromise
<
any
>
{
le
t
importPromise
=
TPromise
.
as
(
null
).
then
(()
=>
{
cons
t
importPromise
=
TPromise
.
as
(
null
).
then
(()
=>
{
le
t
input
=
context
.
input
;
cons
t
input
=
context
.
input
;
if
(
input
.
files
&&
input
.
files
.
length
>
0
)
{
if
(
input
.
files
&&
input
.
files
.
length
>
0
)
{
// Find parent for import
// Find parent for import
...
@@ -869,9 +869,9 @@ export class ImportFileAction extends BaseFileAction {
...
@@ -869,9 +869,9 @@ export class ImportFileAction extends BaseFileAction {
}
}
// Create real files array
// Create real files array
le
t
filesArray
:
File
[]
=
[];
cons
t
filesArray
:
File
[]
=
[];
for
(
let
i
=
0
;
i
<
input
.
files
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
input
.
files
.
length
;
i
++
)
{
le
t
file
=
input
.
files
[
i
];
cons
t
file
=
input
.
files
[
i
];
filesArray
.
push
(
file
);
filesArray
.
push
(
file
);
}
}
...
@@ -879,7 +879,7 @@ export class ImportFileAction extends BaseFileAction {
...
@@ -879,7 +879,7 @@ export class ImportFileAction extends BaseFileAction {
return
this
.
fileService
.
resolveFile
(
targetElement
.
resource
).
then
((
targetStat
:
IFileStat
)
=>
{
return
this
.
fileService
.
resolveFile
(
targetElement
.
resource
).
then
((
targetStat
:
IFileStat
)
=>
{
// Check for name collisions
// Check for name collisions
le
t
targetNames
:
{
[
name
:
string
]:
IFileStat
}
=
{};
cons
t
targetNames
:
{
[
name
:
string
]:
IFileStat
}
=
{};
targetStat
.
children
.
forEach
((
child
)
=>
{
targetStat
.
children
.
forEach
((
child
)
=>
{
targetNames
[
isLinux
?
child
.
name
:
child
.
name
.
toLowerCase
()]
=
child
;
targetNames
[
isLinux
?
child
.
name
:
child
.
name
.
toLowerCase
()]
=
child
;
});
});
...
@@ -888,7 +888,7 @@ export class ImportFileAction extends BaseFileAction {
...
@@ -888,7 +888,7 @@ export class ImportFileAction extends BaseFileAction {
if
(
filesArray
.
some
((
file
)
=>
{
if
(
filesArray
.
some
((
file
)
=>
{
return
!!
targetNames
[
isLinux
?
file
.
name
:
file
.
name
.
toLowerCase
()];
return
!!
targetNames
[
isLinux
?
file
.
name
:
file
.
name
.
toLowerCase
()];
}))
{
}))
{
le
t
confirm
:
IConfirmation
=
{
cons
t
confirm
:
IConfirmation
=
{
message
:
nls
.
localize
(
'
confirmOverwrite
'
,
"
A file or folder with the same name already exists in the destination folder. Do you want to replace it?
"
),
message
:
nls
.
localize
(
'
confirmOverwrite
'
,
"
A file or folder with the same name already exists in the destination folder. Do you want to replace it?
"
),
detail
:
nls
.
localize
(
'
irreversible
'
,
"
This action is irreversible!
"
),
detail
:
nls
.
localize
(
'
irreversible
'
,
"
This action is irreversible!
"
),
primaryButton
:
nls
.
localize
({
key
:
'
replaceButtonLabel
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
&&Replace
"
)
primaryButton
:
nls
.
localize
({
key
:
'
replaceButtonLabel
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
&&Replace
"
)
...
@@ -902,16 +902,16 @@ export class ImportFileAction extends BaseFileAction {
...
@@ -902,16 +902,16 @@ export class ImportFileAction extends BaseFileAction {
}
}
// Run import in sequence
// Run import in sequence
le
t
importPromisesFactory
:
ITask
<
TPromise
<
void
>>
[]
=
[];
cons
t
importPromisesFactory
:
ITask
<
TPromise
<
void
>>
[]
=
[];
filesArray
.
forEach
((
file
)
=>
{
filesArray
.
forEach
((
file
)
=>
{
importPromisesFactory
.
push
(()
=>
{
importPromisesFactory
.
push
(()
=>
{
le
t
sourceFile
=
URI
.
file
((
<
any
>
file
).
path
);
cons
t
sourceFile
=
URI
.
file
((
<
any
>
file
).
path
);
return
this
.
fileService
.
importFile
(
sourceFile
,
targetElement
.
resource
).
then
((
result
:
IImportResult
)
=>
{
return
this
.
fileService
.
importFile
(
sourceFile
,
targetElement
.
resource
).
then
((
result
:
IImportResult
)
=>
{
if
(
result
.
stat
)
{
if
(
result
.
stat
)
{
// Emit Deleted Event if file gets replaced unless it is the same file
// Emit Deleted Event if file gets replaced unless it is the same file
le
t
oldFile
=
targetNames
[
isLinux
?
file
.
name
:
file
.
name
.
toLowerCase
()];
cons
t
oldFile
=
targetNames
[
isLinux
?
file
.
name
:
file
.
name
.
toLowerCase
()];
if
(
oldFile
&&
oldFile
.
resource
.
fsPath
!==
result
.
stat
.
resource
.
fsPath
)
{
if
(
oldFile
&&
oldFile
.
resource
.
fsPath
!==
result
.
stat
.
resource
.
fsPath
)
{
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
new
LocalFileChangeEvent
(
oldFile
,
null
));
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
new
LocalFileChangeEvent
(
oldFile
,
null
));
}
}
...
@@ -1039,8 +1039,8 @@ export class PasteFileAction extends BaseFileAction {
...
@@ -1039,8 +1039,8 @@ export class PasteFileAction extends BaseFileAction {
}
}
// Check if file was deleted or moved meanwhile
// Check if file was deleted or moved meanwhile
le
t
root
:
FileStat
=
this
.
tree
.
getInput
();
cons
t
root
:
FileStat
=
this
.
tree
.
getInput
();
le
t
exists
=
root
.
find
(
fileToCopy
.
resource
);
cons
t
exists
=
root
.
find
(
fileToCopy
.
resource
);
if
(
!
exists
)
{
if
(
!
exists
)
{
fileToCopy
=
null
;
fileToCopy
=
null
;
return
false
;
return
false
;
...
@@ -1065,7 +1065,7 @@ export class PasteFileAction extends BaseFileAction {
...
@@ -1065,7 +1065,7 @@ export class PasteFileAction extends BaseFileAction {
}
}
// Reuse duplicate action
// Reuse duplicate action
le
t
pasteAction
=
this
.
instantiationService
.
createInstance
(
DuplicateFileAction
,
this
.
tree
,
fileToCopy
,
target
);
cons
t
pasteAction
=
this
.
instantiationService
.
createInstance
(
DuplicateFileAction
,
this
.
tree
,
fileToCopy
,
target
);
return
pasteAction
.
run
().
then
(()
=>
{
return
pasteAction
.
run
().
then
(()
=>
{
this
.
tree
.
DOMFocus
();
this
.
tree
.
DOMFocus
();
...
@@ -1105,7 +1105,7 @@ export class DuplicateFileAction extends BaseFileAction {
...
@@ -1105,7 +1105,7 @@ export class DuplicateFileAction extends BaseFileAction {
}
}
// Copy File and emit event
// Copy File and emit event
le
t
result
=
this
.
fileService
.
copyFile
(
this
.
element
.
resource
,
this
.
findTarget
()).
then
((
stat
:
IFileStat
)
=>
{
cons
t
result
=
this
.
fileService
.
copyFile
(
this
.
element
.
resource
,
this
.
findTarget
()).
then
((
stat
:
IFileStat
)
=>
{
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
new
LocalFileChangeEvent
(
null
,
stat
));
this
.
eventService
.
emit
(
'
files.internal:fileChanged
'
,
new
LocalFileChangeEvent
(
null
,
stat
));
},
(
error
:
any
)
=>
{
},
(
error
:
any
)
=>
{
this
.
onError
(
error
);
this
.
onError
(
error
);
...
@@ -1119,7 +1119,7 @@ export class DuplicateFileAction extends BaseFileAction {
...
@@ -1119,7 +1119,7 @@ export class DuplicateFileAction extends BaseFileAction {
}
}
private
findTarget
():
URI
{
private
findTarget
():
URI
{
le
t
root
:
FileStat
=
this
.
tree
.
getInput
();
cons
t
root
:
FileStat
=
this
.
tree
.
getInput
();
let
name
=
this
.
element
.
name
;
let
name
=
this
.
element
.
name
;
let
candidate
=
URI
.
file
(
paths
.
join
(
this
.
target
.
resource
.
fsPath
,
name
));
let
candidate
=
URI
.
file
(
paths
.
join
(
this
.
target
.
resource
.
fsPath
,
name
));
...
@@ -1143,7 +1143,7 @@ export class DuplicateFileAction extends BaseFileAction {
...
@@ -1143,7 +1143,7 @@ export class DuplicateFileAction extends BaseFileAction {
}
}
// file.txt=>file.1.txt
// file.txt=>file.1.txt
le
t
lastIndexOfDot
=
name
.
lastIndexOf
(
'
.
'
);
cons
t
lastIndexOfDot
=
name
.
lastIndexOf
(
'
.
'
);
if
(
!
isFolder
&&
lastIndexOfDot
>=
0
)
{
if
(
!
isFolder
&&
lastIndexOfDot
>=
0
)
{
return
strings
.
format
(
'
{0}.1{1}
'
,
name
.
substr
(
0
,
lastIndexOfDot
),
name
.
substr
(
lastIndexOfDot
));
return
strings
.
format
(
'
{0}.1{1}
'
,
name
.
substr
(
0
,
lastIndexOfDot
),
name
.
substr
(
lastIndexOfDot
));
}
}
...
@@ -1184,7 +1184,7 @@ export class OpenToSideAction extends Action {
...
@@ -1184,7 +1184,7 @@ export class OpenToSideAction extends Action {
}
}
private
updateEnablement
():
void
{
private
updateEnablement
():
void
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
this
.
enabled
=
(
!
activeEditor
||
activeEditor
.
position
!==
Position
.
RIGHT
);
this
.
enabled
=
(
!
activeEditor
||
activeEditor
.
position
!==
Position
.
RIGHT
);
}
}
...
@@ -1251,19 +1251,19 @@ export class GlobalCompareResourcesAction extends Action {
...
@@ -1251,19 +1251,19 @@ export class GlobalCompareResourcesAction extends Action {
}
}
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
le
t
fileInput
=
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
());
cons
t
fileInput
=
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
());
if
(
fileInput
)
{
if
(
fileInput
)
{
// Keep as resource to compare
// Keep as resource to compare
globalResourceToCompare
=
fileInput
.
getResource
();
globalResourceToCompare
=
fileInput
.
getResource
();
// Listen for next editor to open
// Listen for next editor to open
le
t
unbind
=
this
.
editorGroupService
.
onEditorOpening
(
e
=>
{
cons
t
unbind
=
this
.
editorGroupService
.
onEditorOpening
(
e
=>
{
unbind
.
dispose
();
// listen once
unbind
.
dispose
();
// listen once
le
t
otherFileInput
=
asFileEditorInput
(
e
.
editorInput
);
cons
t
otherFileInput
=
asFileEditorInput
(
e
.
editorInput
);
if
(
otherFileInput
)
{
if
(
otherFileInput
)
{
le
t
compareAction
=
this
.
instantiationService
.
createInstance
(
CompareResourcesAction
,
otherFileInput
.
getResource
(),
null
);
cons
t
compareAction
=
this
.
instantiationService
.
createInstance
(
CompareResourcesAction
,
otherFileInput
.
getResource
(),
null
);
if
(
compareAction
.
_isEnabled
())
{
if
(
compareAction
.
_isEnabled
())
{
e
.
prevent
();
e
.
prevent
();
...
@@ -1326,9 +1326,9 @@ export class CompareResourcesAction extends Action {
...
@@ -1326,9 +1326,9 @@ export class CompareResourcesAction extends Action {
// Check if file was deleted or moved meanwhile (explorer only)
// Check if file was deleted or moved meanwhile (explorer only)
if
(
this
.
tree
)
{
if
(
this
.
tree
)
{
le
t
root
:
FileStat
=
this
.
tree
.
getInput
();
cons
t
root
:
FileStat
=
this
.
tree
.
getInput
();
if
(
root
instanceof
FileStat
)
{
if
(
root
instanceof
FileStat
)
{
le
t
exists
=
root
.
find
(
globalResourceToCompare
);
cons
t
exists
=
root
.
find
(
globalResourceToCompare
);
if
(
!
exists
)
{
if
(
!
exists
)
{
globalResourceToCompare
=
null
;
globalResourceToCompare
=
null
;
return
false
;
return
false
;
...
@@ -1341,8 +1341,8 @@ export class CompareResourcesAction extends Action {
...
@@ -1341,8 +1341,8 @@ export class CompareResourcesAction extends Action {
return
false
;
return
false
;
}
}
le
t
mimeA
=
guessMimeTypes
(
this
.
resource
.
fsPath
).
join
(
'
,
'
);
cons
t
mimeA
=
guessMimeTypes
(
this
.
resource
.
fsPath
).
join
(
'
,
'
);
le
t
mimeB
=
guessMimeTypes
(
globalResourceToCompare
.
fsPath
).
join
(
'
,
'
);
cons
t
mimeB
=
guessMimeTypes
(
globalResourceToCompare
.
fsPath
).
join
(
'
,
'
);
// Check if target has same mime
// Check if target has same mime
if
(
mimeA
===
mimeB
)
{
if
(
mimeA
===
mimeB
)
{
...
@@ -1350,8 +1350,8 @@ export class CompareResourcesAction extends Action {
...
@@ -1350,8 +1350,8 @@ export class CompareResourcesAction extends Action {
}
}
// Ensure the mode is equal if this is text (limitation of current diff infrastructure)
// Ensure the mode is equal if this is text (limitation of current diff infrastructure)
le
t
isBinaryA
=
isBinaryMime
(
mimeA
);
cons
t
isBinaryA
=
isBinaryMime
(
mimeA
);
le
t
isBinaryB
=
isBinaryMime
(
mimeB
);
cons
t
isBinaryB
=
isBinaryMime
(
mimeB
);
// Ensure we are not comparing binary with text
// Ensure we are not comparing binary with text
if
(
isBinaryA
!==
isBinaryB
)
{
if
(
isBinaryA
!==
isBinaryB
)
{
...
@@ -1368,8 +1368,8 @@ export class CompareResourcesAction extends Action {
...
@@ -1368,8 +1368,8 @@ export class CompareResourcesAction extends Action {
this
.
tree
.
clearHighlight
();
this
.
tree
.
clearHighlight
();
}
}
le
t
leftInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
globalResourceToCompare
,
void
0
,
void
0
);
cons
t
leftInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
globalResourceToCompare
,
void
0
,
void
0
);
le
t
rightInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
this
.
resource
,
void
0
,
void
0
);
cons
t
rightInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
this
.
resource
,
void
0
,
void
0
);
return
this
.
editorService
.
openEditor
(
new
DiffEditorInput
(
toDiffLabel
(
globalResourceToCompare
,
this
.
resource
,
this
.
contextService
),
null
,
leftInput
,
rightInput
));
return
this
.
editorService
.
openEditor
(
new
DiffEditorInput
(
toDiffLabel
(
globalResourceToCompare
,
this
.
resource
,
this
.
contextService
),
null
,
leftInput
,
rightInput
));
}
}
...
@@ -1438,7 +1438,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
...
@@ -1438,7 +1438,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
if
(
this
.
isSaveAs
()
||
source
.
scheme
===
'
untitled
'
)
{
if
(
this
.
isSaveAs
()
||
source
.
scheme
===
'
untitled
'
)
{
let
mimeOfSource
:
string
;
let
mimeOfSource
:
string
;
if
(
source
.
scheme
===
'
untitled
'
)
{
if
(
source
.
scheme
===
'
untitled
'
)
{
le
t
selectedMime
=
this
.
untitledEditorService
.
get
(
source
).
getMime
();
cons
t
selectedMime
=
this
.
untitledEditorService
.
get
(
source
).
getMime
();
if
(
!
isUnspecific
(
selectedMime
))
{
if
(
!
isUnspecific
(
selectedMime
))
{
mimeOfSource
=
[
selectedMime
,
MIME_TEXT
].
join
(
'
,
'
);
mimeOfSource
=
[
selectedMime
,
MIME_TEXT
].
join
(
'
,
'
);
}
}
...
@@ -1448,7 +1448,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
...
@@ -1448,7 +1448,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
if
(
source
.
scheme
===
'
untitled
'
)
{
if
(
source
.
scheme
===
'
untitled
'
)
{
encodingOfSource
=
this
.
untitledEditorService
.
get
(
source
).
getEncoding
();
encodingOfSource
=
this
.
untitledEditorService
.
get
(
source
).
getEncoding
();
}
else
if
(
source
.
scheme
===
'
file
'
)
{
}
else
if
(
source
.
scheme
===
'
file
'
)
{
le
t
textModel
=
this
.
textFileService
.
models
.
get
(
source
);
cons
t
textModel
=
this
.
textFileService
.
models
.
get
(
source
);
encodingOfSource
=
textModel
&&
textModel
.
getEncoding
();
// text model can be null e.g. if this is a binary file!
encodingOfSource
=
textModel
&&
textModel
.
getEncoding
();
// text model can be null e.g. if this is a binary file!
}
}
...
@@ -1737,7 +1737,7 @@ export class RevertFileAction extends Action {
...
@@ -1737,7 +1737,7 @@ export class RevertFileAction extends Action {
if
(
this
.
resource
)
{
if
(
this
.
resource
)
{
resource
=
this
.
resource
;
resource
=
this
.
resource
;
}
else
{
}
else
{
le
t
activeFileInput
=
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
(),
true
);
cons
t
activeFileInput
=
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
(),
true
);
if
(
activeFileInput
)
{
if
(
activeFileInput
)
{
resource
=
activeFileInput
.
getResource
();
resource
=
activeFileInput
.
getResource
();
}
}
...
@@ -1816,7 +1816,7 @@ export class ShowActiveFileInExplorer extends Action {
...
@@ -1816,7 +1816,7 @@ export class ShowActiveFileInExplorer extends Action {
}
}
public
run
():
TPromise
<
any
>
{
public
run
():
TPromise
<
any
>
{
le
t
fileInput
=
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
(),
true
);
cons
t
fileInput
=
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
(),
true
);
if
(
fileInput
)
{
if
(
fileInput
)
{
return
this
.
viewletService
.
openViewlet
(
VIEWLET_ID
,
false
).
then
((
viewlet
:
ExplorerViewlet
)
=>
{
return
this
.
viewletService
.
openViewlet
(
VIEWLET_ID
,
false
).
then
((
viewlet
:
ExplorerViewlet
)
=>
{
const
isInsideWorkspace
=
this
.
contextService
.
isInsideWorkspace
(
fileInput
.
getResource
());
const
isInsideWorkspace
=
this
.
contextService
.
isInsideWorkspace
(
fileInput
.
getResource
());
...
@@ -1948,7 +1948,7 @@ export function validateFileName(parent: IFileStat, name: string, allowOverwriti
...
@@ -1948,7 +1948,7 @@ export function validateFileName(parent: IFileStat, name: string, allowOverwriti
// Max length restriction (on Windows)
// Max length restriction (on Windows)
if
(
isWindows
)
{
if
(
isWindows
)
{
le
t
fullPathLength
=
name
.
length
+
parent
.
resource
.
fsPath
.
length
+
1
/* path segment */
;
cons
t
fullPathLength
=
name
.
length
+
parent
.
resource
.
fsPath
.
length
+
1
/* path segment */
;
if
(
fullPathLength
>
255
)
{
if
(
fullPathLength
>
255
)
{
return
nls
.
localize
(
'
filePathTooLongError
'
,
"
The name **{0}** results in a path that is too long. Please choose a shorter name.
"
,
name
);
return
nls
.
localize
(
'
filePathTooLongError
'
,
"
The name **{0}** results in a path that is too long. Please choose a shorter name.
"
,
name
);
}
}
...
...
src/vs/workbench/parts/files/browser/saveErrorHandler.ts
浏览文件 @
4acd22df
...
@@ -329,8 +329,7 @@ export class AcceptLocalChangesAction extends EditorInputAction {
...
@@ -329,8 +329,7 @@ export class AcceptLocalChangesAction extends EditorInputAction {
}
}
// Reopen file input
// Reopen file input
const
input
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
model
.
getResource
(),
guessMimeTypes
(
model
.
getResource
().
fsPath
).
join
(
'
,
'
),
void
0
);
return
this
.
editorService
.
openEditor
({
resource
:
model
.
getResource
()
},
this
.
position
).
then
(()
=>
{
return
this
.
editorService
.
openEditor
(
input
,
null
,
this
.
position
).
then
(()
=>
{
// Dispose conflict input
// Dispose conflict input
conflictInput
.
dispose
();
conflictInput
.
dispose
();
...
...
src/vs/workbench/parts/files/browser/views/explorerView.ts
浏览文件 @
4acd22df
...
@@ -108,7 +108,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -108,7 +108,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
public
renderHeader
(
container
:
HTMLElement
):
void
{
public
renderHeader
(
container
:
HTMLElement
):
void
{
le
t
titleDiv
=
$
(
'
div.title
'
).
appendTo
(
container
);
cons
t
titleDiv
=
$
(
'
div.title
'
).
appendTo
(
container
);
$
(
'
span
'
).
text
(
this
.
workspace
.
name
).
title
(
labels
.
getPathLabel
(
this
.
workspace
.
resource
.
fsPath
)).
appendTo
(
titleDiv
);
$
(
'
span
'
).
text
(
this
.
workspace
.
name
).
title
(
labels
.
getPathLabel
(
this
.
workspace
.
resource
.
fsPath
)).
appendTo
(
titleDiv
);
super
.
renderHeader
(
container
);
super
.
renderHeader
(
container
);
...
@@ -136,7 +136,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -136,7 +136,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Set Order
// Set Order
for
(
let
i
=
0
;
i
<
actions
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
actions
.
length
;
i
++
)
{
le
t
action
=
actions
[
i
];
cons
t
action
=
actions
[
i
];
action
.
order
=
10
*
(
i
+
1
);
action
.
order
=
10
*
(
i
+
1
);
}
}
...
@@ -161,7 +161,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -161,7 +161,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
private
onEditorsChanged
():
void
{
private
onEditorsChanged
():
void
{
le
t
activeInput
=
this
.
editorService
.
getActiveEditorInput
();
cons
t
activeInput
=
this
.
editorService
.
getActiveEditorInput
();
let
clearSelection
=
true
;
let
clearSelection
=
true
;
let
clearFocus
=
false
;
let
clearFocus
=
false
;
...
@@ -174,7 +174,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -174,7 +174,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Select file if input is FileEditorInput
// Select file if input is FileEditorInput
if
(
this
.
isVisible
&&
this
.
contextService
.
isInsideWorkspace
(
fileResource
))
{
if
(
this
.
isVisible
&&
this
.
contextService
.
isInsideWorkspace
(
fileResource
))
{
le
t
selection
=
this
.
hasSelection
(
fileResource
);
cons
t
selection
=
this
.
hasSelection
(
fileResource
);
if
(
!
selection
)
{
if
(
!
selection
)
{
this
.
select
(
fileResource
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
select
(
fileResource
).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
...
@@ -224,7 +224,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -224,7 +224,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Make sure the current selected element is revealed
// Make sure the current selected element is revealed
if
(
this
.
explorerViewer
)
{
if
(
this
.
explorerViewer
)
{
if
(
this
.
autoReveal
)
{
if
(
this
.
autoReveal
)
{
le
t
selection
=
this
.
explorerViewer
.
getSelection
();
cons
t
selection
=
this
.
explorerViewer
.
getSelection
();
if
(
selection
.
length
>
0
)
{
if
(
selection
.
length
>
0
)
{
this
.
reveal
(
selection
[
0
],
0.5
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
reveal
(
selection
[
0
],
0.5
).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
...
@@ -236,7 +236,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -236,7 +236,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
// Open the focused element in the editor if there is currently no file opened
// Open the focused element in the editor if there is currently no file opened
le
t
input
=
this
.
editorService
.
getActiveEditorInput
();
cons
t
input
=
this
.
editorService
.
getActiveEditorInput
();
if
(
!
input
||
!
(
input
instanceof
FileEditorInput
))
{
if
(
!
input
||
!
(
input
instanceof
FileEditorInput
))
{
this
.
openFocusedElement
(
keepFocus
);
this
.
openFocusedElement
(
keepFocus
);
}
}
...
@@ -256,7 +256,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -256,7 +256,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
// Always select the current navigated file in explorer if input is file editor input
// Always select the current navigated file in explorer if input is file editor input
le
t
activeResource
=
this
.
getActiveEditorInputResource
();
cons
t
activeResource
=
this
.
getActiveEditorInputResource
();
if
(
activeResource
)
{
if
(
activeResource
)
{
return
refreshPromise
.
then
(()
=>
{
return
refreshPromise
.
then
(()
=>
{
return
this
.
select
(
activeResource
);
return
this
.
select
(
activeResource
);
...
@@ -269,15 +269,14 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -269,15 +269,14 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
// Otherwise restore last used file: By lastActiveFileResource
// Otherwise restore last used file: By lastActiveFileResource
le
t
root
=
this
.
getInput
();
cons
t
root
=
this
.
getInput
();
let
lastActiveFileResource
:
URI
;
let
lastActiveFileResource
:
URI
;
if
(
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
])
{
if
(
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
])
{
lastActiveFileResource
=
URI
.
parse
(
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
]);
lastActiveFileResource
=
URI
.
parse
(
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
]);
}
}
if
(
lastActiveFileResource
&&
root
&&
root
.
find
(
lastActiveFileResource
))
{
if
(
lastActiveFileResource
&&
root
&&
root
.
find
(
lastActiveFileResource
))
{
let
editorInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
lastActiveFileResource
,
void
0
,
void
0
);
this
.
editorService
.
openEditor
({
resource
:
lastActiveFileResource
,
options
:
{
revealIfVisible
:
true
}
}).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
editorService
.
openEditor
(
editorInput
,
{
revealIfVisible
:
true
}).
done
(
null
,
errors
.
onUnexpectedError
);
return
refreshPromise
;
return
refreshPromise
;
}
}
...
@@ -291,9 +290,9 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -291,9 +290,9 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
private
openFocusedElement
(
preserveFocus
?:
boolean
):
void
{
private
openFocusedElement
(
preserveFocus
?:
boolean
):
void
{
le
t
stat
:
FileStat
=
this
.
explorerViewer
.
getFocus
();
cons
t
stat
:
FileStat
=
this
.
explorerViewer
.
getFocus
();
if
(
stat
&&
!
stat
.
isDirectory
)
{
if
(
stat
&&
!
stat
.
isDirectory
)
{
le
t
editorInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
stat
.
resource
,
stat
.
mime
,
void
0
);
cons
t
editorInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
stat
.
resource
,
stat
.
mime
,
void
0
);
this
.
editorService
.
openEditor
(
editorInput
,
{
preserveFocus
,
revealIfVisible
:
true
}).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
editorService
.
openEditor
(
editorInput
,
{
preserveFocus
,
revealIfVisible
:
true
}).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
...
@@ -302,7 +301,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -302,7 +301,7 @@ export class ExplorerView extends CollapsibleViewletView {
private
getActiveEditorInputResource
():
URI
{
private
getActiveEditorInputResource
():
URI
{
// Try with Editor Input
// Try with Editor Input
le
t
input
=
this
.
editorService
.
getActiveEditorInput
();
cons
t
input
=
this
.
editorService
.
getActiveEditorInput
();
if
(
input
&&
input
instanceof
FileEditorInput
)
{
if
(
input
&&
input
instanceof
FileEditorInput
)
{
return
(
<
FileEditorInput
>
input
).
getResource
();
return
(
<
FileEditorInput
>
input
).
getResource
();
}
}
...
@@ -332,9 +331,9 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -332,9 +331,9 @@ export class ExplorerView extends CollapsibleViewletView {
dnd
,
dnd
,
accessibilityProvider
accessibilityProvider
},
{
},
{
autoExpandSingleChildren
:
true
,
autoExpandSingleChildren
:
true
,
ariaLabel
:
nls
.
localize
(
'
treeAriaLabel
'
,
"
Files Explorer
"
)
ariaLabel
:
nls
.
localize
(
'
treeAriaLabel
'
,
"
Files Explorer
"
)
});
});
this
.
toDispose
.
push
(
lifecycle
.
toDisposable
(()
=>
renderer
.
dispose
()));
this
.
toDispose
.
push
(
lifecycle
.
toDisposable
(()
=>
renderer
.
dispose
()));
...
@@ -352,8 +351,8 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -352,8 +351,8 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
public
getOptimalWidth
():
number
{
public
getOptimalWidth
():
number
{
le
t
parentNode
=
this
.
explorerViewer
.
getHTMLElement
();
cons
t
parentNode
=
this
.
explorerViewer
.
getHTMLElement
();
le
t
childNodes
=
[].
slice
.
call
(
parentNode
.
querySelectorAll
(
'
.explorer-item-label > a
'
));
cons
t
childNodes
=
[].
slice
.
call
(
parentNode
.
querySelectorAll
(
'
.explorer-item-label > a
'
));
return
DOM
.
getLargestChildWidth
(
parentNode
,
childNodes
);
return
DOM
.
getLargestChildWidth
(
parentNode
,
childNodes
);
}
}
...
@@ -366,18 +365,18 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -366,18 +365,18 @@ export class ExplorerView extends CollapsibleViewletView {
// Add
// Add
if
(
e
.
gotAdded
())
{
if
(
e
.
gotAdded
())
{
le
t
addedElement
=
e
.
getAfter
();
cons
t
addedElement
=
e
.
getAfter
();
parentResource
=
URI
.
file
(
paths
.
dirname
(
addedElement
.
resource
.
fsPath
));
parentResource
=
URI
.
file
(
paths
.
dirname
(
addedElement
.
resource
.
fsPath
));
parentElement
=
this
.
getInput
().
find
(
parentResource
);
parentElement
=
this
.
getInput
().
find
(
parentResource
);
if
(
parentElement
)
{
if
(
parentElement
)
{
// Add the new file to its parent (Model)
// Add the new file to its parent (Model)
le
t
childElement
=
FileStat
.
create
(
addedElement
);
cons
t
childElement
=
FileStat
.
create
(
addedElement
);
parentElement
.
removeChild
(
childElement
);
// make sure to remove any previous version of the file if any
parentElement
.
removeChild
(
childElement
);
// make sure to remove any previous version of the file if any
parentElement
.
addChild
(
childElement
);
parentElement
.
addChild
(
childElement
);
le
t
refreshPromise
=
()
=>
{
cons
t
refreshPromise
=
()
=>
{
// Refresh the Parent (View)
// Refresh the Parent (View)
return
this
.
explorerViewer
.
refresh
(
parentElement
).
then
(()
=>
{
return
this
.
explorerViewer
.
refresh
(
parentElement
).
then
(()
=>
{
...
@@ -408,15 +407,15 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -408,15 +407,15 @@ export class ExplorerView extends CollapsibleViewletView {
// Move (including Rename)
// Move (including Rename)
else
if
(
e
.
gotMoved
())
{
else
if
(
e
.
gotMoved
())
{
le
t
oldElement
=
e
.
getBefore
();
cons
t
oldElement
=
e
.
getBefore
();
le
t
newElement
=
e
.
getAfter
();
cons
t
newElement
=
e
.
getAfter
();
le
t
oldParentResource
=
URI
.
file
(
paths
.
dirname
(
oldElement
.
resource
.
fsPath
));
cons
t
oldParentResource
=
URI
.
file
(
paths
.
dirname
(
oldElement
.
resource
.
fsPath
));
le
t
newParentResource
=
URI
.
file
(
paths
.
dirname
(
newElement
.
resource
.
fsPath
));
cons
t
newParentResource
=
URI
.
file
(
paths
.
dirname
(
newElement
.
resource
.
fsPath
));
// Only update focus if renamed/moved element is selected
// Only update focus if renamed/moved element is selected
let
updateFocus
=
false
;
let
updateFocus
=
false
;
le
t
focus
:
FileStat
=
this
.
explorerViewer
.
getFocus
();
cons
t
focus
:
FileStat
=
this
.
explorerViewer
.
getFocus
();
if
(
focus
&&
focus
.
resource
&&
focus
.
resource
.
toString
()
===
oldElement
.
resource
.
toString
())
{
if
(
focus
&&
focus
.
resource
&&
focus
.
resource
.
toString
()
===
oldElement
.
resource
.
toString
())
{
updateFocus
=
true
;
updateFocus
=
true
;
}
}
...
@@ -448,8 +447,8 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -448,8 +447,8 @@ export class ExplorerView extends CollapsibleViewletView {
// Handle Move
// Handle Move
else
if
(
oldParentResource
&&
newParentResource
)
{
else
if
(
oldParentResource
&&
newParentResource
)
{
le
t
oldParent
=
this
.
getInput
().
find
(
oldParentResource
);
cons
t
oldParent
=
this
.
getInput
().
find
(
oldParentResource
);
le
t
newParent
=
this
.
getInput
().
find
(
newParentResource
);
cons
t
newParent
=
this
.
getInput
().
find
(
newParentResource
);
modelElement
=
this
.
getInput
().
find
(
oldElement
.
resource
);
modelElement
=
this
.
getInput
().
find
(
oldElement
.
resource
);
if
(
oldParent
&&
newParent
&&
modelElement
)
{
if
(
oldParent
&&
newParent
&&
modelElement
)
{
...
@@ -472,7 +471,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -472,7 +471,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Delete
// Delete
else
if
(
e
.
gotDeleted
())
{
else
if
(
e
.
gotDeleted
())
{
le
t
deletedElement
=
e
.
getBefore
();
cons
t
deletedElement
=
e
.
getBefore
();
modelElement
=
this
.
getInput
().
find
(
deletedElement
.
resource
);
modelElement
=
this
.
getInput
().
find
(
deletedElement
.
resource
);
if
(
modelElement
&&
modelElement
.
parent
)
{
if
(
modelElement
&&
modelElement
.
parent
)
{
parent
=
modelElement
.
parent
;
parent
=
modelElement
.
parent
;
...
@@ -491,7 +490,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -491,7 +490,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Imported which replaced an existing file
// Imported which replaced an existing file
else
if
(
e
instanceof
FileImportedEvent
)
{
else
if
(
e
instanceof
FileImportedEvent
)
{
le
t
importedElement
:
IFileStat
=
(
<
FileImportedEvent
>
e
).
getAfter
();
cons
t
importedElement
:
IFileStat
=
(
<
FileImportedEvent
>
e
).
getAfter
();
parentResource
=
URI
.
file
(
paths
.
dirname
(
importedElement
.
resource
.
fsPath
));
parentResource
=
URI
.
file
(
paths
.
dirname
(
importedElement
.
resource
.
fsPath
));
parentElement
=
this
.
getInput
().
find
(
parentResource
);
parentElement
=
this
.
getInput
().
find
(
parentResource
);
...
@@ -513,7 +512,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -513,7 +512,7 @@ export class ExplorerView extends CollapsibleViewletView {
// delete events can result in UI activity that will fill the memento again when multiple
// delete events can result in UI activity that will fill the memento again when multiple
// editors are closing)
// editors are closing)
setTimeout
(()
=>
{
setTimeout
(()
=>
{
le
t
lastActiveResource
:
string
=
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
];
cons
t
lastActiveResource
:
string
=
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
];
if
(
lastActiveResource
&&
e
.
contains
(
URI
.
parse
(
lastActiveResource
),
FileChangeType
.
DELETED
))
{
if
(
lastActiveResource
&&
e
.
contains
(
URI
.
parse
(
lastActiveResource
),
FileChangeType
.
DELETED
))
{
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
]
=
null
;
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
]
=
null
;
}
}
...
@@ -542,24 +541,24 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -542,24 +541,24 @@ export class ExplorerView extends CollapsibleViewletView {
// We only ever refresh from files/folders that got added or deleted
// We only ever refresh from files/folders that got added or deleted
if
(
e
.
gotAdded
()
||
e
.
gotDeleted
())
{
if
(
e
.
gotAdded
()
||
e
.
gotDeleted
())
{
le
t
added
=
e
.
getAdded
();
cons
t
added
=
e
.
getAdded
();
le
t
deleted
=
e
.
getDeleted
();
cons
t
deleted
=
e
.
getDeleted
();
le
t
root
=
this
.
getInput
();
cons
t
root
=
this
.
getInput
();
if
(
!
root
)
{
if
(
!
root
)
{
return
false
;
return
false
;
}
}
// Check added: Refresh if added file/folder is not part of resolved root and parent is part of it
// Check added: Refresh if added file/folder is not part of resolved root and parent is part of it
le
t
ignoredPaths
:
{
[
fsPath
:
string
]:
boolean
}
=
<
{
[
fsPath
:
string
]:
boolean
}
>
{};
cons
t
ignoredPaths
:
{
[
fsPath
:
string
]:
boolean
}
=
<
{
[
fsPath
:
string
]:
boolean
}
>
{};
for
(
let
i
=
0
;
i
<
added
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
added
.
length
;
i
++
)
{
le
t
change
=
added
[
i
];
cons
t
change
=
added
[
i
];
if
(
!
this
.
contextService
.
isInsideWorkspace
(
change
.
resource
))
{
if
(
!
this
.
contextService
.
isInsideWorkspace
(
change
.
resource
))
{
continue
;
// out of workspace file
continue
;
// out of workspace file
}
}
// Find parent
// Find parent
le
t
parent
=
paths
.
dirname
(
change
.
resource
.
fsPath
);
cons
t
parent
=
paths
.
dirname
(
change
.
resource
.
fsPath
);
// Continue if parent was already determined as to be ignored
// Continue if parent was already determined as to be ignored
if
(
ignoredPaths
[
parent
])
{
if
(
ignoredPaths
[
parent
])
{
...
@@ -567,7 +566,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -567,7 +566,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
// Compute if parent is visible and added file not yet part of it
// Compute if parent is visible and added file not yet part of it
le
t
parentStat
=
root
.
find
(
URI
.
file
(
parent
));
cons
t
parentStat
=
root
.
find
(
URI
.
file
(
parent
));
if
(
parentStat
&&
parentStat
.
isDirectoryResolved
&&
!
root
.
find
(
change
.
resource
))
{
if
(
parentStat
&&
parentStat
.
isDirectoryResolved
&&
!
root
.
find
(
change
.
resource
))
{
return
true
;
return
true
;
}
}
...
@@ -580,7 +579,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -580,7 +579,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Check deleted: Refresh if deleted file/folder part of resolved root
// Check deleted: Refresh if deleted file/folder part of resolved root
for
(
let
j
=
0
;
j
<
deleted
.
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
deleted
.
length
;
j
++
)
{
le
t
del
=
deleted
[
j
];
cons
t
del
=
deleted
[
j
];
if
(
!
this
.
contextService
.
isInsideWorkspace
(
del
.
resource
))
{
if
(
!
this
.
contextService
.
isInsideWorkspace
(
del
.
resource
))
{
continue
;
// out of workspace file
continue
;
// out of workspace file
}
}
...
@@ -600,12 +599,12 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -600,12 +599,12 @@ export class ExplorerView extends CollapsibleViewletView {
return
false
;
// we only want added / removed
return
false
;
// we only want added / removed
}
}
le
t
workspacePath
=
this
.
contextService
.
toWorkspaceRelativePath
(
change
.
resource
);
cons
t
workspacePath
=
this
.
contextService
.
toWorkspaceRelativePath
(
change
.
resource
);
if
(
!
workspacePath
)
{
if
(
!
workspacePath
)
{
return
false
;
// not inside workspace
return
false
;
// not inside workspace
}
}
le
t
segments
=
workspacePath
.
split
(
/
\/
/
);
cons
t
segments
=
workspacePath
.
split
(
/
\/
/
);
return
fn
(
change
,
segments
);
return
fn
(
change
,
segments
);
}));
}));
...
@@ -641,7 +640,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -641,7 +640,7 @@ export class ExplorerView extends CollapsibleViewletView {
if
(
this
.
autoReveal
)
{
if
(
this
.
autoReveal
)
{
resourceToFocus
=
this
.
getActiveEditorInputResource
();
resourceToFocus
=
this
.
getActiveEditorInputResource
();
if
(
!
resourceToFocus
)
{
if
(
!
resourceToFocus
)
{
le
t
selection
=
this
.
explorerViewer
.
getSelection
();
cons
t
selection
=
this
.
explorerViewer
.
getSelection
();
if
(
selection
&&
selection
.
length
===
1
)
{
if
(
selection
&&
selection
.
length
===
1
)
{
resourceToFocus
=
(
<
FileStat
>
selection
[
0
]).
resource
;
resourceToFocus
=
(
<
FileStat
>
selection
[
0
]).
resource
;
}
}
...
@@ -658,8 +657,8 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -658,8 +657,8 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
private
doRefresh
():
TPromise
<
void
>
{
private
doRefresh
():
TPromise
<
void
>
{
le
t
root
=
this
.
getInput
();
cons
t
root
=
this
.
getInput
();
le
t
targetsToResolve
:
URI
[]
=
[];
cons
t
targetsToResolve
:
URI
[]
=
[];
let
targetsToExpand
:
URI
[]
=
[];
let
targetsToExpand
:
URI
[]
=
[];
if
(
this
.
settings
[
ExplorerView
.
MEMENTO_EXPANDED_FOLDER_RESOURCES
])
{
if
(
this
.
settings
[
ExplorerView
.
MEMENTO_EXPANDED_FOLDER_RESOURCES
])
{
...
@@ -668,7 +667,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -668,7 +667,7 @@ export class ExplorerView extends CollapsibleViewletView {
// First time refresh: Receive target through active editor input or selection and also include settings from previous session
// First time refresh: Receive target through active editor input or selection and also include settings from previous session
if
(
!
root
)
{
if
(
!
root
)
{
le
t
activeResource
=
this
.
getActiveEditorInputResource
();
cons
t
activeResource
=
this
.
getActiveEditorInputResource
();
if
(
activeResource
)
{
if
(
activeResource
)
{
targetsToResolve
.
push
(
activeResource
);
targetsToResolve
.
push
(
activeResource
);
}
}
...
@@ -684,12 +683,12 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -684,12 +683,12 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
// Load Root Stat with given target path configured
// Load Root Stat with given target path configured
le
t
options
:
IResolveFileOptions
=
{
resolveTo
:
targetsToResolve
};
cons
t
options
:
IResolveFileOptions
=
{
resolveTo
:
targetsToResolve
};
le
t
promise
=
this
.
fileService
.
resolveFile
(
this
.
workspace
.
resource
,
options
).
then
(
stat
=>
{
cons
t
promise
=
this
.
fileService
.
resolveFile
(
this
.
workspace
.
resource
,
options
).
then
(
stat
=>
{
let
explorerPromise
:
TPromise
<
void
>
;
let
explorerPromise
:
TPromise
<
void
>
;
// Convert to model
// Convert to model
le
t
modelStat
=
FileStat
.
create
(
stat
,
options
.
resolveTo
);
cons
t
modelStat
=
FileStat
.
create
(
stat
,
options
.
resolveTo
);
// First time refresh: The stat becomes the input of the viewer
// First time refresh: The stat becomes the input of the viewer
if
(
!
root
)
{
if
(
!
root
)
{
...
@@ -728,7 +727,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -728,7 +727,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Drop those path which are parents of the current one
// Drop those path which are parents of the current one
for
(
let
i
=
resolvedDirectories
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
let
i
=
resolvedDirectories
.
length
-
1
;
i
>=
0
;
i
--
)
{
le
t
resource
=
resolvedDirectories
[
i
];
cons
t
resource
=
resolvedDirectories
[
i
];
if
(
stat
.
resource
.
toString
().
indexOf
(
resource
.
toString
())
===
0
)
{
if
(
stat
.
resource
.
toString
().
indexOf
(
resource
.
toString
())
===
0
)
{
resolvedDirectories
.
splice
(
i
);
resolvedDirectories
.
splice
(
i
);
}
}
...
@@ -740,7 +739,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -740,7 +739,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Recurse into children
// Recurse into children
for
(
let
i
=
0
;
i
<
stat
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
stat
.
children
.
length
;
i
++
)
{
le
t
child
=
stat
.
children
[
i
];
cons
t
child
=
stat
.
children
[
i
];
this
.
getResolvedDirectories
(
child
,
resolvedDirectories
);
this
.
getResolvedDirectories
(
child
,
resolvedDirectories
);
}
}
}
}
...
@@ -758,28 +757,28 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -758,28 +757,28 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
// If path already selected, just reveal and return
// If path already selected, just reveal and return
le
t
selection
=
this
.
hasSelection
(
resource
);
cons
t
selection
=
this
.
hasSelection
(
resource
);
if
(
selection
)
{
if
(
selection
)
{
return
reveal
?
this
.
reveal
(
selection
,
0.5
)
:
TPromise
.
as
(
null
);
return
reveal
?
this
.
reveal
(
selection
,
0.5
)
:
TPromise
.
as
(
null
);
}
}
// First try to get the stat object from the input to avoid a roundtrip
// First try to get the stat object from the input to avoid a roundtrip
le
t
root
=
this
.
getInput
();
cons
t
root
=
this
.
getInput
();
if
(
!
root
)
{
if
(
!
root
)
{
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
le
t
fileStat
=
root
.
find
(
resource
);
cons
t
fileStat
=
root
.
find
(
resource
);
if
(
fileStat
)
{
if
(
fileStat
)
{
return
this
.
doSelect
(
fileStat
,
reveal
);
return
this
.
doSelect
(
fileStat
,
reveal
);
}
}
// Stat needs to be resolved first and then revealed
// Stat needs to be resolved first and then revealed
le
t
options
:
IResolveFileOptions
=
{
resolveTo
:
[
resource
]
};
cons
t
options
:
IResolveFileOptions
=
{
resolveTo
:
[
resource
]
};
return
this
.
fileService
.
resolveFile
(
this
.
workspace
.
resource
,
options
).
then
(
stat
=>
{
return
this
.
fileService
.
resolveFile
(
this
.
workspace
.
resource
,
options
).
then
(
stat
=>
{
// Convert to model
// Convert to model
le
t
modelStat
=
FileStat
.
create
(
stat
,
options
.
resolveTo
);
cons
t
modelStat
=
FileStat
.
create
(
stat
,
options
.
resolveTo
);
// Update Input with disk Stat
// Update Input with disk Stat
FileStat
.
mergeLocalWithDisk
(
modelStat
,
root
);
FileStat
.
mergeLocalWithDisk
(
modelStat
,
root
);
...
@@ -791,7 +790,7 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -791,7 +790,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
private
hasSelection
(
resource
:
URI
):
FileStat
{
private
hasSelection
(
resource
:
URI
):
FileStat
{
le
t
currentSelection
:
FileStat
[]
=
this
.
explorerViewer
.
getSelection
();
cons
t
currentSelection
:
FileStat
[]
=
this
.
explorerViewer
.
getSelection
();
for
(
let
i
=
0
;
i
<
currentSelection
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
currentSelection
.
length
;
i
++
)
{
if
(
currentSelection
[
i
].
resource
.
toString
()
===
resource
.
toString
())
{
if
(
currentSelection
[
i
].
resource
.
toString
()
===
resource
.
toString
())
{
...
@@ -836,9 +835,9 @@ export class ExplorerView extends CollapsibleViewletView {
...
@@ -836,9 +835,9 @@ export class ExplorerView extends CollapsibleViewletView {
public
shutdown
():
void
{
public
shutdown
():
void
{
// Keep list of expanded folders to restore on next load
// Keep list of expanded folders to restore on next load
le
t
root
=
this
.
getInput
();
cons
t
root
=
this
.
getInput
();
if
(
root
)
{
if
(
root
)
{
le
t
expanded
=
this
.
explorerViewer
.
getExpandedElements
()
cons
t
expanded
=
this
.
explorerViewer
.
getExpandedElements
()
.
filter
((
e
:
FileStat
)
=>
e
.
resource
.
toString
()
!==
this
.
workspace
.
resource
.
toString
())
.
filter
((
e
:
FileStat
)
=>
e
.
resource
.
toString
()
!==
this
.
workspace
.
resource
.
toString
())
.
map
((
e
:
FileStat
)
=>
e
.
resource
.
toString
());
.
map
((
e
:
FileStat
)
=>
e
.
resource
.
toString
());
...
...
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
浏览文件 @
4acd22df
...
@@ -25,7 +25,6 @@ import {IDisposable} from 'vs/base/common/lifecycle';
...
@@ -25,7 +25,6 @@ import {IDisposable} from 'vs/base/common/lifecycle';
import
{
ContributableActionProvider
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
ContributableActionProvider
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
LocalFileChangeEvent
,
IFilesConfiguration
,
ITextFileService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
LocalFileChangeEvent
,
IFilesConfiguration
,
ITextFileService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFileOperationResult
,
FileOperationResult
,
IFileStat
,
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileOperationResult
,
FileOperationResult
,
IFileStat
,
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
import
{
DuplicateFileAction
,
ImportFileAction
,
PasteFileAction
,
keybindingForAction
,
IEditableData
,
IFileViewletState
}
from
'
vs/workbench/parts/files/browser/fileActions
'
;
import
{
DuplicateFileAction
,
ImportFileAction
,
PasteFileAction
,
keybindingForAction
,
IEditableData
,
IFileViewletState
}
from
'
vs/workbench/parts/files/browser/fileActions
'
;
import
{
IDataSource
,
ITree
,
IElementCallback
,
IAccessibilityProvider
,
IRenderer
,
ContextMenuEvent
,
ISorter
,
IFilter
,
IDragAndDrop
,
IDragAndDropData
,
IDragOverReaction
,
DRAG_OVER_ACCEPT_BUBBLE_DOWN
,
DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY
,
DRAG_OVER_ACCEPT_BUBBLE_UP
,
DRAG_OVER_ACCEPT_BUBBLE_UP_COPY
,
DRAG_OVER_REJECT
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
IDataSource
,
ITree
,
IElementCallback
,
IAccessibilityProvider
,
IRenderer
,
ContextMenuEvent
,
ISorter
,
IFilter
,
IDragAndDrop
,
IDragAndDropData
,
IDragOverReaction
,
DRAG_OVER_ACCEPT_BUBBLE_DOWN
,
DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY
,
DRAG_OVER_ACCEPT_BUBBLE_UP
,
DRAG_OVER_ACCEPT_BUBBLE_UP_COPY
,
DRAG_OVER_REJECT
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
DesktopDragAndDropData
,
ExternalElementsDragAndDropData
}
from
'
vs/base/parts/tree/browser/treeDnd
'
;
import
{
DesktopDragAndDropData
,
ExternalElementsDragAndDropData
}
from
'
vs/base/parts/tree/browser/treeDnd
'
;
...
@@ -679,8 +678,7 @@ export class FileController extends DefaultController {
...
@@ -679,8 +678,7 @@ export class FileController extends DefaultController {
if
(
stat
&&
!
stat
.
isDirectory
)
{
if
(
stat
&&
!
stat
.
isDirectory
)
{
this
.
telemetryService
.
publicLog
(
'
workbenchActionExecuted
'
,
{
id
:
'
workbench.files.openFile
'
,
from
:
'
explorer
'
});
this
.
telemetryService
.
publicLog
(
'
workbenchActionExecuted
'
,
{
id
:
'
workbench.files.openFile
'
,
from
:
'
explorer
'
});
const
editorInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
stat
.
resource
,
stat
.
mime
,
void
0
);
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
mime
:
stat
.
mime
,
options
:
{
preserveFocus
,
pinned
}
},
sideBySide
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
editorService
.
openEditor
(
editorInput
,
{
preserveFocus
,
pinned
},
sideBySide
).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
}
}
...
...
src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts
浏览文件 @
4acd22df
...
@@ -107,8 +107,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
...
@@ -107,8 +107,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
}
}
// Reopen
// Reopen
const
editorInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
reopenFileResource
,
mimeHint
||
MIME_UNKNOWN
,
void
0
);
this
.
editorService
.
openEditor
({
resource
:
reopenFileResource
,
mime
:
mimeHint
||
MIME_UNKNOWN
,
options
:
{
preserveFocus
:
true
,
pinned
:
group
.
isPinned
(
input
),
index
:
group
.
indexOf
(
input
),
inactive
:
!
group
.
isActive
(
input
)
}
},
stacks
.
positionOfGroup
(
group
)).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
editorService
.
openEditor
(
editorInput
,
{
preserveFocus
:
true
,
pinned
:
group
.
isPinned
(
input
),
index
:
group
.
indexOf
(
input
),
inactive
:
!
group
.
isActive
(
input
)
},
stacks
.
positionOfGroup
(
group
)).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
}
}
});
});
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
4acd22df
...
@@ -80,7 +80,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -80,7 +80,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
}
if
(
includeDiff
&&
editor
.
input
instanceof
DiffEditorInput
)
{
if
(
includeDiff
&&
editor
.
input
instanceof
DiffEditorInput
)
{
le
t
diffInput
=
<
DiffEditorInput
>
editor
.
input
;
cons
t
diffInput
=
<
DiffEditorInput
>
editor
.
input
;
return
input
.
matches
(
diffInput
.
modifiedInput
)
||
input
.
matches
(
diffInput
.
originalInput
);
return
input
.
matches
(
diffInput
.
modifiedInput
)
||
input
.
matches
(
diffInput
.
originalInput
);
}
}
...
@@ -103,9 +103,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -103,9 +103,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
}
// Support opening foreign resources (such as a http link that points outside of the workbench)
// Support opening foreign resources (such as a http link that points outside of the workbench)
le
t
resourceInput
=
<
IResourceInput
>
input
;
cons
t
resourceInput
=
<
IResourceInput
>
input
;
if
(
resourceInput
.
resource
instanceof
URI
)
{
if
(
resourceInput
.
resource
instanceof
URI
)
{
le
t
schema
=
resourceInput
.
resource
.
scheme
;
cons
t
schema
=
resourceInput
.
resource
.
scheme
;
if
(
schema
===
network
.
Schemas
.
http
||
schema
===
network
.
Schemas
.
https
)
{
if
(
schema
===
network
.
Schemas
.
http
||
schema
===
network
.
Schemas
.
https
)
{
window
.
open
(
resourceInput
.
resource
.
toString
(
true
));
window
.
open
(
resourceInput
.
resource
.
toString
(
true
));
return
TPromise
.
as
<
IEditor
>
(
null
);
return
TPromise
.
as
<
IEditor
>
(
null
);
...
@@ -113,10 +113,10 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -113,10 +113,10 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
}
// Untyped Text Editor Support (required for code that uses this service below workbench level)
// Untyped Text Editor Support (required for code that uses this service below workbench level)
le
t
textInput
=
<
IResourceInput
>
input
;
cons
t
textInput
=
<
IResourceInput
>
input
;
return
this
.
createInput
(
textInput
).
then
(
(
typedFileInput
:
EditorInput
)
=>
{
return
this
.
createInput
(
textInput
).
then
(
typedInput
=>
{
if
(
typed
File
Input
)
{
if
(
typedInput
)
{
return
this
.
doOpenEditor
(
typed
File
Input
,
TextEditorOptions
.
from
(
textInput
),
arg2
);
return
this
.
doOpenEditor
(
typedInput
,
TextEditorOptions
.
from
(
textInput
),
arg2
);
}
}
return
TPromise
.
as
<
IEditor
>
(
null
);
return
TPromise
.
as
<
IEditor
>
(
null
);
...
@@ -198,13 +198,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -198,13 +198,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
public
resolveEditorModel
(
input
:
IEditorInput
,
refresh
?:
boolean
):
TPromise
<
IEditorModel
>
;
public
resolveEditorModel
(
input
:
IEditorInput
,
refresh
?:
boolean
):
TPromise
<
IEditorModel
>
;
public
resolveEditorModel
(
input
:
IResourceInput
,
refresh
?:
boolean
):
TPromise
<
ITextEditorModel
>
;
public
resolveEditorModel
(
input
:
IResourceInput
,
refresh
?:
boolean
):
TPromise
<
ITextEditorModel
>
;
public
resolveEditorModel
(
input
:
any
,
refresh
?:
boolean
):
TPromise
<
IEditorModel
>
{
public
resolveEditorModel
(
input
:
any
,
refresh
?:
boolean
):
TPromise
<
IEditorModel
>
{
return
this
.
createInput
(
input
).
then
((
workbenchInput
:
IEditorInput
)
=>
{
return
this
.
createInput
(
input
).
then
(
typedInput
=>
{
if
(
workbenchInput
)
{
if
(
typedInput
instanceof
EditorInput
)
{
return
typedInput
.
resolve
(
!!
refresh
);
// Resolve if applicable
if
(
workbenchInput
instanceof
EditorInput
)
{
return
workbenchInput
.
resolve
(
!!
refresh
);
}
}
}
return
TPromise
.
as
<
IEditorModel
>
(
null
);
return
TPromise
.
as
<
IEditorModel
>
(
null
);
...
@@ -221,21 +217,21 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -221,21 +217,21 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
}
// Base Text Editor Support for inmemory resources
// Base Text Editor Support for inmemory resources
le
t
resourceInput
=
<
IResourceInput
>
input
;
cons
t
resourceInput
=
<
IResourceInput
>
input
;
if
(
resourceInput
.
resource
instanceof
URI
&&
resourceInput
.
resource
.
scheme
===
network
.
Schemas
.
inMemory
)
{
if
(
resourceInput
.
resource
instanceof
URI
&&
resourceInput
.
resource
.
scheme
===
network
.
Schemas
.
inMemory
)
{
// For in-memory resources we only support to resolve the input from the current active editor
// For in-memory resources we only support to resolve the input from the current active editor
// because the workbench does not track editor models by in memory URL. This concept is only
// because the workbench does not track editor models by in memory URL. This concept is only
// being used in the code editor.
// being used in the code editor.
le
t
activeEditor
=
this
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
getActiveEditor
();
if
(
activeEditor
)
{
if
(
activeEditor
)
{
le
t
control
=
<
ICommonEditor
>
activeEditor
.
getControl
();
cons
t
control
=
<
ICommonEditor
>
activeEditor
.
getControl
();
if
(
types
.
isFunction
(
control
.
getEditorType
))
{
if
(
types
.
isFunction
(
control
.
getEditorType
))
{
// Single Editor: If code editor model matches, return input from editor
// Single Editor: If code editor model matches, return input from editor
if
(
control
.
getEditorType
()
===
EditorType
.
ICodeEditor
)
{
if
(
control
.
getEditorType
()
===
EditorType
.
ICodeEditor
)
{
le
t
codeEditor
=
<
ICodeEditor
>
control
;
cons
t
codeEditor
=
<
ICodeEditor
>
control
;
le
t
model
=
this
.
findModel
(
codeEditor
,
input
);
cons
t
model
=
this
.
findModel
(
codeEditor
,
input
);
if
(
model
)
{
if
(
model
)
{
return
TPromise
.
as
(
activeEditor
.
input
);
return
TPromise
.
as
(
activeEditor
.
input
);
}
}
...
@@ -243,15 +239,15 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -243,15 +239,15 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
// Diff Editor: If left or right code editor model matches, return associated input
// Diff Editor: If left or right code editor model matches, return associated input
else
if
(
control
.
getEditorType
()
===
EditorType
.
IDiffEditor
)
{
else
if
(
control
.
getEditorType
()
===
EditorType
.
IDiffEditor
)
{
le
t
diffInput
=
<
DiffEditorInput
>
activeEditor
.
input
;
cons
t
diffInput
=
<
DiffEditorInput
>
activeEditor
.
input
;
le
t
diffCodeEditor
=
<
IDiffEditor
>
control
;
cons
t
diffCodeEditor
=
<
IDiffEditor
>
control
;
le
t
originalModel
=
this
.
findModel
(
diffCodeEditor
.
getOriginalEditor
(),
input
);
cons
t
originalModel
=
this
.
findModel
(
diffCodeEditor
.
getOriginalEditor
(),
input
);
if
(
originalModel
)
{
if
(
originalModel
)
{
return
TPromise
.
as
(
diffInput
.
originalInput
);
return
TPromise
.
as
(
diffInput
.
originalInput
);
}
}
le
t
modifiedModel
=
this
.
findModel
(
diffCodeEditor
.
getModifiedEditor
(),
input
);
cons
t
modifiedModel
=
this
.
findModel
(
diffCodeEditor
.
getModifiedEditor
(),
input
);
if
(
modifiedModel
)
{
if
(
modifiedModel
)
{
return
TPromise
.
as
(
diffInput
.
modifiedInput
);
return
TPromise
.
as
(
diffInput
.
modifiedInput
);
}
}
...
@@ -292,7 +288,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -292,7 +288,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
}
private
findModel
(
editor
:
ICommonCodeEditor
,
input
:
IResourceInput
):
IModel
{
private
findModel
(
editor
:
ICommonCodeEditor
,
input
:
IResourceInput
):
IModel
{
le
t
model
=
editor
.
getModel
();
cons
t
model
=
editor
.
getModel
();
if
(
!
model
)
{
if
(
!
model
)
{
return
null
;
return
null
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录