Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
32dfe5dd
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,发现更多精彩内容 >>
提交
32dfe5dd
编写于
5月 06, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #66338
上级
abd57bb0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
30 deletion
+59
-30
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+4
-0
src/vs/workbench/services/textfile/common/textFileService.ts
src/vs/workbench/services/textfile/common/textFileService.ts
+23
-24
src/vs/workbench/services/textfile/node/textResourcePropertiesService.ts
...h/services/textfile/node/textResourcePropertiesService.ts
+1
-1
src/vs/workbench/services/textfile/test/textFileEditorModel.test.ts
...kbench/services/textfile/test/textFileEditorModel.test.ts
+29
-1
src/vs/workbench/services/textfile/test/textFileService.test.ts
.../workbench/services/textfile/test/textFileService.test.ts
+2
-4
未找到文件。
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
32dfe5dd
...
...
@@ -859,6 +859,10 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
// Updated resolved stat with updated stat since touching it might have changed mtime
this
.
updateLastResolvedDiskStat
(
stat
);
// Emit File Saved Event
this
.
_onDidStateChange
.
fire
(
StateChange
.
SAVED
);
},
error
=>
onUnexpectedError
(
error
)
/* just log any error but do not notify the user since the file was not dirty */
));
}
...
...
src/vs/workbench/services/textfile/common/textFileService.ts
浏览文件 @
32dfe5dd
...
...
@@ -246,37 +246,36 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
.
map
(
async
untitled
=>
(
await
this
.
untitledEditorService
.
loadOrCreate
({
resource
:
untitled
})).
backup
()));
}
private
confirmBeforeShutdown
():
boolean
|
Promise
<
boolean
>
{
return
this
.
confirmSave
().
then
(
confirm
=>
{
// Save
if
(
confirm
===
ConfirmResult
.
SAVE
)
{
return
this
.
saveAll
(
true
/* includeUntitled */
,
{
skipSaveParticipants
:
true
}).
then
(
result
=>
{
if
(
result
.
results
.
some
(
r
=>
!
r
.
success
))
{
return
true
;
// veto if some saves failed
}
private
async
confirmBeforeShutdown
():
Promise
<
boolean
>
{
const
confirm
=
await
this
.
confirmSave
();
return
this
.
noVeto
({
cleanUpBackups
:
true
});
});
// Save
if
(
confirm
===
ConfirmResult
.
SAVE
)
{
const
result
=
await
this
.
saveAll
(
true
/* includeUntitled */
,
{
skipSaveParticipants
:
true
});
if
(
result
.
results
.
some
(
r
=>
!
r
.
success
))
{
return
true
;
// veto if some saves failed
}
// Don't Save
else
if
(
confirm
===
ConfirmResult
.
DONT_SAVE
)
{
return
this
.
noVeto
({
cleanUpBackups
:
true
});
}
// Make sure to revert untitled so that they do not restore
// see https://github.com/Microsoft/vscode/issues/29572
this
.
untitledEditorService
.
revertAll
();
// Don't Save
else
if
(
confirm
===
ConfirmResult
.
DONT_SAVE
)
{
return
this
.
noVeto
({
cleanUpBackups
:
true
});
}
// Make sure to revert untitled so that they do not restore
// see https://github.com/Microsoft/vscode/issues/29572
this
.
untitledEditorService
.
revertAll
();
// Cancel
else
if
(
confirm
===
ConfirmResult
.
CANCEL
)
{
return
true
;
// veto
}
return
this
.
noVeto
({
cleanUpBackups
:
true
});
}
return
false
;
});
// Cancel
else
if
(
confirm
===
ConfirmResult
.
CANCEL
)
{
return
true
;
// veto
}
return
false
;
}
private
noVeto
(
options
:
{
cleanUpBackups
:
boolean
}):
boolean
|
Promise
<
boolean
>
{
...
...
src/vs/workbench/services/textfile/node/textResourcePropertiesService.ts
浏览文件 @
32dfe5dd
...
...
@@ -17,7 +17,7 @@ import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiatio
export
class
TextResourcePropertiesService
implements
ITextResourcePropertiesService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
_serviceBrand
:
ServiceIdentifier
<
ITextResourcePropertiesService
>
;
private
remoteEnvironment
:
IRemoteAgentEnvironment
|
null
=
null
;
...
...
src/vs/workbench/services/textfile/test/textFileEditorModel.test.ts
浏览文件 @
32dfe5dd
...
...
@@ -44,7 +44,7 @@ suite('Files - TextFileEditorModel', () => {
accessor
.
fileService
.
setContent
(
content
);
});
test
(
'
S
ave
'
,
async
function
()
{
test
(
'
s
ave
'
,
async
function
()
{
const
model
:
TextFileEditorModel
=
instantiationService
.
createInstance
(
TextFileEditorModel
,
toResource
.
call
(
this
,
'
/path/index_async.txt
'
),
'
utf8
'
);
await
model
.
load
();
...
...
@@ -52,10 +52,38 @@ suite('Files - TextFileEditorModel', () => {
model
.
textEditorModel
!
.
setValue
(
'
bar
'
);
assert
.
ok
(
getLastModifiedTime
(
model
)
<=
Date
.
now
());
let
savedEvent
=
false
;
model
.
onDidStateChange
(
e
=>
{
if
(
e
===
StateChange
.
SAVED
)
{
savedEvent
=
true
;
}
});
await
model
.
save
();
assert
.
ok
(
model
.
getLastSaveAttemptTime
()
<=
Date
.
now
());
assert
.
ok
(
!
model
.
isDirty
());
assert
.
ok
(
savedEvent
);
model
.
dispose
();
assert
.
ok
(
!
accessor
.
modelService
.
getModel
(
model
.
getResource
()));
});
test
(
'
save - touching also emits saved event
'
,
async
function
()
{
const
model
:
TextFileEditorModel
=
instantiationService
.
createInstance
(
TextFileEditorModel
,
toResource
.
call
(
this
,
'
/path/index_async.txt
'
),
'
utf8
'
);
await
model
.
load
();
let
savedEvent
=
false
;
model
.
onDidStateChange
(
e
=>
{
if
(
e
===
StateChange
.
SAVED
)
{
savedEvent
=
true
;
}
});
await
model
.
save
({
force
:
true
});
assert
.
ok
(
savedEvent
);
model
.
dispose
();
assert
.
ok
(
!
accessor
.
modelService
.
getModel
(
model
.
getResource
()));
...
...
src/vs/workbench/services/textfile/test/textFileService.test.ts
浏览文件 @
32dfe5dd
...
...
@@ -65,7 +65,7 @@ suite('Files - TextFileService', () => {
accessor
.
untitledEditorService
.
revertAll
();
});
test
(
'
confirm onWillShutdown - no veto
'
,
function
()
{
test
(
'
confirm onWillShutdown - no veto
'
,
async
function
()
{
model
=
instantiationService
.
createInstance
(
TextFileEditorModel
,
toResource
.
call
(
this
,
'
/path/file.txt
'
),
'
utf8
'
);
(
<
TextFileEditorModelManager
>
accessor
.
textFileService
.
models
).
add
(
model
.
getResource
(),
model
);
...
...
@@ -76,9 +76,7 @@ suite('Files - TextFileService', () => {
if
(
typeof
veto
===
'
boolean
'
)
{
assert
.
ok
(
!
veto
);
}
else
{
veto
.
then
(
veto
=>
{
assert
.
ok
(
!
veto
);
});
assert
.
ok
(
!
(
await
veto
));
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录