Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ff1d5301
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,发现更多精彩内容 >>
提交
ff1d5301
编写于
3月 05, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null work in files/browser
上级
db9a994d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
14 deletion
+33
-14
src/vs/workbench/contrib/files/browser/fileActions.ts
src/vs/workbench/contrib/files/browser/fileActions.ts
+23
-4
src/vs/workbench/contrib/files/browser/fileCommands.ts
src/vs/workbench/contrib/files/browser/fileCommands.ts
+7
-7
src/vs/workbench/contrib/files/browser/saveErrorHandler.ts
src/vs/workbench/contrib/files/browser/saveErrorHandler.ts
+2
-2
src/vs/workbench/services/editor/common/editorService.ts
src/vs/workbench/services/editor/common/editorService.ts
+1
-1
未找到文件。
src/vs/workbench/contrib/files/browser/fileActions.ts
浏览文件 @
ff1d5301
...
...
@@ -832,7 +832,7 @@ export class ShowActiveFileInExplorer extends Action {
}
public
run
():
Promise
<
any
>
{
const
resource
=
toResource
(
this
.
editorService
.
activeEditor
,
{
supportSideBySide
:
true
});
const
resource
=
toResource
(
this
.
editorService
.
activeEditor
||
null
,
{
supportSideBySide
:
true
});
if
(
resource
)
{
this
.
commandService
.
executeCommand
(
REVEAL_IN_EXPLORER_COMMAND_ID
,
resource
);
}
else
{
...
...
@@ -904,7 +904,7 @@ export class ShowOpenedFileInNewWindow extends Action {
}
public
run
():
Promise
<
any
>
{
const
fileResource
=
toResource
(
this
.
editorService
.
activeEditor
,
{
supportSideBySide
:
true
});
const
fileResource
=
toResource
(
this
.
editorService
.
activeEditor
||
null
,
{
supportSideBySide
:
true
});
if
(
fileResource
)
{
if
(
this
.
fileService
.
canHandleResource
(
fileResource
))
{
this
.
windowService
.
openWindow
([{
uri
:
fileResource
,
typeHint
:
'
file
'
}],
{
forceNewWindow
:
true
,
forceOpenWorkspaceAsFile
:
true
});
...
...
@@ -1007,7 +1007,7 @@ export class CompareWithClipboardAction extends Action {
}
public
run
():
Promise
<
any
>
{
const
resource
=
toResource
(
this
.
editorService
.
activeEditor
,
{
supportSideBySide
:
true
});
const
resource
=
toResource
(
this
.
editorService
.
activeEditor
||
null
,
{
supportSideBySide
:
true
});
if
(
resource
&&
(
this
.
fileService
.
canHandleResource
(
resource
)
||
resource
.
scheme
===
Schemas
.
untitled
))
{
if
(
!
this
.
registrationDisposal
)
{
const
provider
=
this
.
instantiationService
.
createInstance
(
ClipboardContentProvider
);
...
...
@@ -1076,7 +1076,7 @@ function openExplorerAndRunAction(accessor: ServicesAccessor, constructor: ICons
return
explorerPromise
.
then
((
explorer
:
ExplorerViewlet
)
=>
{
const
explorerView
=
explorer
.
getExplorerView
();
if
(
explorerView
&&
explorerView
.
isBodyVisible
())
{
if
(
explorerView
&&
explorerView
.
isBodyVisible
()
&&
listService
.
lastFocusedList
)
{
explorerView
.
focus
();
const
{
stat
}
=
getContext
(
listService
.
lastFocusedList
);
const
action
=
instantationService
.
createInstance
(
constructor
,
()
=>
stat
);
...
...
@@ -1106,6 +1106,10 @@ export const renameHandler = (accessor: ServicesAccessor) => {
const
listService
=
accessor
.
get
(
IListService
);
const
explorerService
=
accessor
.
get
(
IExplorerService
);
const
textFileService
=
accessor
.
get
(
ITextFileService
);
if
(
!
listService
.
lastFocusedList
)
{
return
;
}
const
{
stat
}
=
getContext
(
listService
.
lastFocusedList
);
explorerService
.
setEditable
(
stat
,
{
...
...
@@ -1124,6 +1128,9 @@ export const renameHandler = (accessor: ServicesAccessor) => {
export
const
moveFileToTrashHandler
=
(
accessor
:
ServicesAccessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
listService
.
lastFocusedList
)
{
return
Promise
.
resolve
();
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
);
const
stats
=
explorerContext
.
selection
.
length
>
1
?
explorerContext
.
selection
:
[
explorerContext
.
stat
];
...
...
@@ -1134,6 +1141,9 @@ export const moveFileToTrashHandler = (accessor: ServicesAccessor) => {
export
const
deleteFileHandler
=
(
accessor
:
ServicesAccessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
listService
.
lastFocusedList
)
{
return
Promise
.
resolve
();
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
);
const
stats
=
explorerContext
.
selection
.
length
>
1
?
explorerContext
.
selection
:
[
explorerContext
.
stat
];
...
...
@@ -1143,6 +1153,9 @@ export const deleteFileHandler = (accessor: ServicesAccessor) => {
export
const
copyFileHandler
=
(
accessor
:
ServicesAccessor
)
=>
{
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
listService
.
lastFocusedList
)
{
return
;
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
);
const
explorerService
=
accessor
.
get
(
IExplorerService
);
const
stats
=
explorerContext
.
selection
.
length
>
1
?
explorerContext
.
selection
:
[
explorerContext
.
stat
];
...
...
@@ -1152,6 +1165,9 @@ export const copyFileHandler = (accessor: ServicesAccessor) => {
export
const
cutFileHandler
=
(
accessor
:
ServicesAccessor
)
=>
{
const
listService
=
accessor
.
get
(
IListService
);
if
(
!
listService
.
lastFocusedList
)
{
return
;
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
);
const
explorerService
=
accessor
.
get
(
IExplorerService
);
const
stats
=
explorerContext
.
selection
.
length
>
1
?
explorerContext
.
selection
:
[
explorerContext
.
stat
];
...
...
@@ -1163,6 +1179,9 @@ export const pasteFileHandler = (accessor: ServicesAccessor) => {
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
const
listService
=
accessor
.
get
(
IListService
);
const
clipboardService
=
accessor
.
get
(
IClipboardService
);
if
(
!
listService
.
lastFocusedList
)
{
return
Promise
.
resolve
();
}
const
explorerContext
=
getContext
(
listService
.
lastFocusedList
);
return
sequence
(
resources
.
distinctParents
(
clipboardService
.
readResources
(),
r
=>
r
).
map
(
toCopy
=>
{
...
...
src/vs/workbench/contrib/files/browser/fileCommands.ts
浏览文件 @
ff1d5301
...
...
@@ -111,7 +111,7 @@ function save(
// Save As (or Save untitled with associated path)
if
(
isSaveAs
||
resource
.
scheme
===
Schemas
.
untitled
)
{
let
encodingOfSource
:
string
;
let
encodingOfSource
:
string
|
undefined
;
if
(
resource
.
scheme
===
Schemas
.
untitled
)
{
encodingOfSource
=
untitledEditorService
.
getEncoding
(
resource
);
}
else
if
(
fileService
.
canHandleResource
(
resource
))
{
...
...
@@ -119,17 +119,17 @@ function save(
encodingOfSource
=
textModel
&&
textModel
.
getEncoding
();
// text model can be null e.g. if this is a binary file!
}
let
viewStateOfSource
:
IEditorViewState
;
let
viewStateOfSource
:
IEditorViewState
|
null
;
const
activeTextEditorWidget
=
getCodeEditor
(
editorService
.
activeTextEditorWidget
);
if
(
activeTextEditorWidget
)
{
const
activeResource
=
toResource
(
editorService
.
activeEditor
,
{
supportSideBySide
:
true
});
const
activeResource
=
toResource
(
editorService
.
activeEditor
||
null
,
{
supportSideBySide
:
true
});
if
(
activeResource
&&
(
fileService
.
canHandleResource
(
activeResource
)
||
resource
.
scheme
===
Schemas
.
untitled
)
&&
activeResource
.
toString
()
===
resource
.
toString
())
{
viewStateOfSource
=
activeTextEditorWidget
.
saveViewState
();
}
}
// Special case: an untitled file with associated path gets saved directly unless "saveAs" is true
let
savePromise
:
Promise
<
URI
>
;
let
savePromise
:
Promise
<
URI
|
null
>
;
if
(
!
isSaveAs
&&
resource
.
scheme
===
Schemas
.
untitled
&&
untitledEditorService
.
hasAssociatedFilePath
(
resource
))
{
savePromise
=
textFileService
.
save
(
resource
,
options
).
then
((
result
)
=>
{
if
(
result
)
{
...
...
@@ -152,7 +152,7 @@ function save(
return
savePromise
.
then
((
target
)
=>
{
if
(
!
target
||
target
.
toString
()
===
resource
.
toString
())
{
return
undefined
;
// save canceled or same resource used
return
false
;
// save canceled or same resource used
}
const
replacement
:
IResourceInput
=
{
...
...
@@ -175,7 +175,7 @@ function save(
// Pin the active editor if we are saving it
const
activeControl
=
editorService
.
activeControl
;
const
activeEditorResource
=
activeControl
&&
activeControl
.
input
&&
activeControl
.
input
.
getResource
();
if
(
activeEditorResource
&&
activeEditorResource
.
toString
()
===
resource
.
toString
())
{
if
(
active
Control
&&
active
EditorResource
&&
activeEditorResource
.
toString
()
===
resource
.
toString
())
{
activeControl
.
group
.
pinEditor
(
activeControl
.
input
);
}
...
...
@@ -203,7 +203,7 @@ function saveAll(saveAllArguments: any, editorService: IEditorService, untitledE
groupIdToUntitledResourceInput
.
set
(
g
.
id
,
[]);
}
groupIdToUntitledResourceInput
.
get
(
g
.
id
).
push
({
groupIdToUntitledResourceInput
.
get
(
g
.
id
)
!
.
push
({
encoding
:
untitledEditorService
.
getEncoding
(
resource
),
resource
,
options
:
{
...
...
src/vs/workbench/contrib/files/browser/saveErrorHandler.ts
浏览文件 @
ff1d5301
...
...
@@ -9,7 +9,7 @@ import { basename } from 'vs/base/common/resources';
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
FileOperationError
,
FileOperationResult
}
from
'
vs/platform/files/common/files
'
;
import
{
ITextFileService
,
ISaveErrorHandler
,
ITextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
,
ISaveErrorHandler
,
ITextFileEditorModel
,
IResolvedTextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDisposable
,
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
...
...
@@ -321,7 +321,7 @@ export const acceptLocalChangesCommand = (accessor: ServicesAccessor, resource:
const
group
=
control
.
group
;
resolverService
.
createModelReference
(
resource
).
then
(
reference
=>
{
const
model
=
reference
.
object
as
ITextFileEditorModel
;
const
model
=
reference
.
object
as
I
Resolved
TextFileEditorModel
;
const
localModelSnapshot
=
model
.
createSnapshot
();
clearPendingResolveSaveConflictMessages
();
// hide any previously shown message about how to use these actions
...
...
src/vs/workbench/services/editor/common/editorService.ts
浏览文件 @
ff1d5301
...
...
@@ -36,7 +36,7 @@ export interface IOpenEditorOverride {
* If defined, will prevent the opening of an editor and replace the resulting
* promise with the provided promise for the openEditor() call.
*/
override
?:
Promise
<
IEditor
|
null
>
;
override
?:
Promise
<
IEditor
|
null
|
undefined
>
;
}
export
interface
IActiveEditor
extends
IEditor
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录