Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
1d727988
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
1d727988
编写于
9月 22, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save participants do not run on shutdown
上级
6fc77109
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
1 deletion
+24
-1
src/vs/platform/lifecycle/common/lifecycle.ts
src/vs/platform/lifecycle/common/lifecycle.ts
+7
-0
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+2
-0
src/vs/workbench/parts/files/common/editors/textFileEditorModel.ts
...rkbench/parts/files/common/editors/textFileEditorModel.ts
+5
-1
src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts
...h/services/lifecycle/electron-browser/lifecycleService.ts
+10
-0
未找到文件。
src/vs/platform/lifecycle/common/lifecycle.ts
浏览文件 @
1d727988
...
...
@@ -32,6 +32,12 @@ export interface ILifecycleService {
_serviceBrand
:
any
;
/**
* A flag indicating if the application is in the process of shutting down. This will be true
* before the onWillShutdown event is fired and false if the shutdown is being vetoed.
*/
willShutdown
:
boolean
;
/**
* Fired before shutdown happens. Allows listeners to veto against the
* shutdown.
...
...
@@ -47,6 +53,7 @@ export interface ILifecycleService {
export
const
NullLifecycleService
:
ILifecycleService
=
{
_serviceBrand
:
null
,
willShutdown
:
false
,
onWillShutdown
:
()
=>
({
dispose
()
{
}
}),
onShutdown
:
()
=>
({
dispose
()
{
}
})
};
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
1d727988
...
...
@@ -607,6 +607,8 @@ export class TestLifecycleService implements ILifecycleService {
public
_serviceBrand
:
any
;
public
willShutdown
:
boolean
;
private
_onWillShutdown
=
new
Emitter
<
ShutdownEvent
>
();
private
_onShutdown
=
new
Emitter
<
void
>
();
...
...
src/vs/workbench/parts/files/common/editors/textFileEditorModel.ts
浏览文件 @
1d727988
...
...
@@ -17,6 +17,7 @@ import diagnostics = require('vs/base/common/diagnostics');
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
IModelContentChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IMode
}
from
'
vs/editor/common/modes
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ITextFileService
,
IAutoSaveConfiguration
,
ModelState
,
ITextFileEditorModel
,
ISaveErrorHandler
,
ISaveParticipant
,
StateChange
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
EncodingMode
,
EditorModel
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseTextEditorModel
}
from
'
vs/workbench/common/editor/textEditorModel
'
;
...
...
@@ -64,6 +65,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
@
IModeService
modeService
:
IModeService
,
@
IModelService
modelService
:
IModelService
,
@
IFileService
private
fileService
:
IFileService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
ITextFileService
private
textFileService
:
ITextFileService
...
...
@@ -441,9 +443,11 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
// A save participant can still change the model now and since we are so close to saving
// we do not want to trigger another auto save or similar, so we block this
// In addition we update our version right after in case it changed because of a model change
// We DO NOT run any save participant if we are in the shutdown phase and files are being
// saved as a result of that.
let
saveParticipantPromise
=
TPromise
.
as
(
versionId
);
if
(
TextFileEditorModel
.
saveParticipant
)
{
if
(
TextFileEditorModel
.
saveParticipant
&&
!
this
.
lifecycleService
.
willShutdown
)
{
saveParticipantPromise
=
TPromise
.
as
(
undefined
).
then
(()
=>
{
this
.
blockModelContentChange
=
true
;
return
TextFileEditorModel
.
saveParticipant
.
participate
(
this
,
{
isAutoSaved
});
...
...
src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts
浏览文件 @
1d727988
...
...
@@ -20,6 +20,8 @@ export class LifecycleService implements ILifecycleService {
private
_onWillShutdown
=
new
Emitter
<
ShutdownEvent
>
();
private
_onShutdown
=
new
Emitter
<
void
>
();
private
_willShutdown
:
boolean
;
constructor
(
@
IMessageService
private
messageService
:
IMessageService
,
@
IWindowService
private
windowService
:
IWindowService
...
...
@@ -27,6 +29,10 @@ export class LifecycleService implements ILifecycleService {
this
.
registerListeners
();
}
public
get
willShutdown
():
boolean
{
return
this
.
_willShutdown
;
}
public
get
onWillShutdown
():
Event
<
ShutdownEvent
>
{
return
this
.
_onWillShutdown
.
event
;
}
...
...
@@ -40,8 +46,12 @@ export class LifecycleService implements ILifecycleService {
// Main side indicates that window is about to unload, check for vetos
ipc
.
on
(
'
vscode:beforeUnload
'
,
(
event
,
reply
:
{
okChannel
:
string
,
cancelChannel
:
string
})
=>
{
this
.
_willShutdown
=
true
;
// trigger onWillShutdown events and veto collecting
this
.
onBeforeUnload
().
done
(
veto
=>
{
if
(
veto
)
{
this
.
_willShutdown
=
false
;
// reset this flag since the shutdown has been vetoed!
ipc
.
send
(
reply
.
cancelChannel
,
windowId
);
}
else
{
this
.
_onShutdown
.
fire
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录