Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
e2e55d63
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e2e55d63
编写于
11月 20, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #85180
上级
07ad6851
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
20 deletion
+15
-20
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+13
-18
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+1
-1
src/vs/workbench/services/textfile/test/textFileService.test.ts
.../workbench/services/textfile/test/textFileService.test.ts
+1
-1
未找到文件。
src/vs/workbench/services/textfile/browser/textFileService.ts
浏览文件 @
e2e55d63
...
@@ -239,7 +239,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
...
@@ -239,7 +239,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
if
(
confirm
===
ConfirmResult
.
SAVE
)
{
if
(
confirm
===
ConfirmResult
.
SAVE
)
{
const
result
=
await
this
.
saveAll
(
true
/* includeUntitled */
,
{
skipSaveParticipants
:
true
});
const
result
=
await
this
.
saveAll
(
true
/* includeUntitled */
,
{
skipSaveParticipants
:
true
});
if
(
result
.
results
.
some
(
r
=>
!
r
.
success
))
{
if
(
result
.
results
.
some
(
r
=>
r
.
error
))
{
return
true
;
// veto if some saves failed
return
true
;
// veto if some saves failed
}
}
...
@@ -492,9 +492,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
...
@@ -492,9 +492,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
}
}
}
}
const
result
=
await
this
.
saveAll
([
resource
],
options
);
return
!
(
await
this
.
saveAll
([
resource
],
options
)).
results
.
some
(
result
=>
result
.
error
);
return
result
.
results
.
length
===
1
&&
!!
result
.
results
[
0
].
success
;
}
}
saveAll
(
includeUntitled
?:
boolean
,
options
?:
ITextFileSaveOptions
):
Promise
<
ITextFileOperationResult
>
;
saveAll
(
includeUntitled
?:
boolean
,
options
?:
ITextFileSaveOptions
):
Promise
<
ITextFileOperationResult
>
;
...
@@ -560,7 +558,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
...
@@ -560,7 +558,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
result
.
results
.
push
({
result
.
results
.
push
({
source
:
untitledResources
[
index
],
source
:
untitledResources
[
index
],
target
:
uri
,
target
:
uri
,
success
:
!!
uri
error
:
!
uri
// the operation was canceled or failed, so mark as error
});
});
}));
}));
...
@@ -648,10 +646,11 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
...
@@ -648,10 +646,11 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
await
Promise
.
all
(
dirtyFileModels
.
map
(
async
model
=>
{
await
Promise
.
all
(
dirtyFileModels
.
map
(
async
model
=>
{
await
model
.
save
(
options
);
await
model
.
save
(
options
);
if
(
!
model
.
isDirty
())
{
// If model is still dirty, mark the resulting operation as error
if
(
model
.
isDirty
())
{
const
result
=
mapResourceToResult
.
get
(
model
.
resource
);
const
result
=
mapResourceToResult
.
get
(
model
.
resource
);
if
(
result
)
{
if
(
result
)
{
result
.
success
=
true
;
result
.
error
=
true
;
}
}
}
}
}));
}));
...
@@ -838,9 +837,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
...
@@ -838,9 +837,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
}
}
async
revert
(
resource
:
URI
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
async
revert
(
resource
:
URI
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
const
result
=
await
this
.
revertAll
([
resource
],
options
);
return
!
(
await
this
.
revertAll
([
resource
],
options
)).
results
.
some
(
result
=>
result
.
error
);
return
result
.
results
.
length
===
1
&&
!!
result
.
results
[
0
].
success
;
}
}
async
revertAll
(
resources
?:
URI
[],
options
?:
IRevertOptions
):
Promise
<
ITextFileOperationResult
>
{
async
revertAll
(
resources
?:
URI
[],
options
?:
IRevertOptions
):
Promise
<
ITextFileOperationResult
>
{
...
@@ -850,7 +847,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
...
@@ -850,7 +847,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
// Revert untitled
// Revert untitled
const
untitledReverted
=
this
.
untitledTextEditorService
.
revertAll
(
resources
);
const
untitledReverted
=
this
.
untitledTextEditorService
.
revertAll
(
resources
);
untitledReverted
.
forEach
(
untitled
=>
revertOperationResult
.
results
.
push
({
source
:
untitled
,
success
:
true
}));
untitledReverted
.
forEach
(
untitled
=>
revertOperationResult
.
results
.
push
({
source
:
untitled
}));
return
revertOperationResult
;
return
revertOperationResult
;
}
}
...
@@ -869,20 +866,18 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
...
@@ -869,20 +866,18 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
try
{
try
{
await
model
.
revert
(
options
);
await
model
.
revert
(
options
);
if
(
!
model
.
isDirty
())
{
// If model is still dirty, mark the resulting operation as error
if
(
model
.
isDirty
())
{
const
result
=
mapResourceToResult
.
get
(
model
.
resource
);
const
result
=
mapResourceToResult
.
get
(
model
.
resource
);
if
(
result
)
{
if
(
result
)
{
result
.
success
=
true
;
result
.
error
=
true
;
}
}
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
// FileNotFound means the file got deleted meanwhile, so
still record as successful rever
t
// FileNotFound means the file got deleted meanwhile, so
ignore i
t
if
((
<
FileOperationError
>
error
).
fileOperationResult
===
FileOperationResult
.
FILE_NOT_FOUND
)
{
if
((
<
FileOperationError
>
error
).
fileOperationResult
===
FileOperationResult
.
FILE_NOT_FOUND
)
{
const
result
=
mapResourceToResult
.
get
(
model
.
resource
);
return
;
if
(
result
)
{
result
.
success
=
true
;
}
}
}
// Otherwise bubble up the error
// Otherwise bubble up the error
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
e2e55d63
...
@@ -309,7 +309,7 @@ export interface ITextFileOperationResult {
...
@@ -309,7 +309,7 @@ export interface ITextFileOperationResult {
export
interface
IResult
{
export
interface
IResult
{
source
:
URI
;
source
:
URI
;
target
?:
URI
;
target
?:
URI
;
success
?:
boolean
;
error
?:
boolean
;
}
}
export
const
enum
LoadReason
{
export
const
enum
LoadReason
{
...
...
src/vs/workbench/services/textfile/test/textFileService.test.ts
浏览文件 @
e2e55d63
...
@@ -205,7 +205,7 @@ suite('Files - TextFileService', () => {
...
@@ -205,7 +205,7 @@ suite('Files - TextFileService', () => {
const
res
=
await
accessor
.
textFileService
.
saveAll
(
true
);
const
res
=
await
accessor
.
textFileService
.
saveAll
(
true
);
assert
.
ok
(
loadOrCreateStub
.
calledOnce
);
assert
.
ok
(
loadOrCreateStub
.
calledOnce
);
assert
.
equal
(
res
.
results
.
length
,
1
);
assert
.
equal
(
res
.
results
.
length
,
1
);
assert
.
ok
(
res
.
results
[
0
].
success
);
assert
.
ok
(
!
res
.
results
[
0
].
error
);
assert
.
equal
(
res
.
results
[
0
].
target
!
.
scheme
,
Schemas
.
file
);
assert
.
equal
(
res
.
results
[
0
].
target
!
.
scheme
,
Schemas
.
file
);
assert
.
equal
(
res
.
results
[
0
].
target
!
.
authority
,
untitledUncUri
.
authority
);
assert
.
equal
(
res
.
results
[
0
].
target
!
.
authority
,
untitledUncUri
.
authority
);
assert
.
equal
(
res
.
results
[
0
].
target
!
.
path
,
untitledUncUri
.
path
);
assert
.
equal
(
res
.
results
[
0
].
target
!
.
path
,
untitledUncUri
.
path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录