Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
94315b86
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,发现更多精彩内容 >>
提交
94315b86
编写于
11月 29, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lifecycle - introduce onShutdown event for disposing things after onWillShutdown
上级
84e975ef
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
75 addition
and
55 deletion
+75
-55
src/vs/platform/lifecycle/common/lifecycle.ts
src/vs/platform/lifecycle/common/lifecycle.ts
+19
-9
src/vs/platform/lifecycle/electron-browser/lifecycleService.ts
...s/platform/lifecycle/electron-browser/lifecycleService.ts
+19
-11
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
+3
-3
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+1
-1
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+7
-10
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+2
-2
src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
...rkbench/parts/tasks/electron-browser/task.contribution.ts
+1
-1
src/vs/workbench/parts/terminal/common/terminalService.ts
src/vs/workbench/parts/terminal/common/terminalService.ts
+2
-2
src/vs/workbench/services/extensions/electron-browser/extensionHost.ts
...nch/services/extensions/electron-browser/extensionHost.ts
+2
-2
src/vs/workbench/services/textfile/common/textFileService.ts
src/vs/workbench/services/textfile/common/textFileService.ts
+1
-1
src/vs/workbench/services/textfile/test/textFileService.test.ts
.../workbench/services/textfile/test/textFileService.test.ts
+7
-7
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+11
-6
未找到文件。
src/vs/platform/lifecycle/common/lifecycle.ts
浏览文件 @
94315b86
...
...
@@ -18,7 +18,7 @@ export const ILifecycleService = createDecorator<ILifecycleService>('lifecycleSe
* Note: It is absolutely important to avoid long running promises if possible. Please try hard
* to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence!
*/
export
interface
Will
ShutdownEvent
{
export
interface
Before
ShutdownEvent
{
/**
* Allows to veto the shutdown. The veto can be a long running operation but it
...
...
@@ -27,7 +27,7 @@ export interface WillShutdownEvent {
veto
(
value
:
boolean
|
Thenable
<
boolean
>
):
void
;
/**
* The reason why
Code
will be shutting down.
* The reason why
the application
will be shutting down.
*/
reason
:
ShutdownReason
;
}
...
...
@@ -40,7 +40,7 @@ export interface WillShutdownEvent {
* Note: It is absolutely important to avoid long running promises if possible. Please try hard
* to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence!
*/
export
interface
ShutdownEvent
{
export
interface
Will
ShutdownEvent
{
/**
* Allows to join the shutdown. The promise can be a long running operation but it
...
...
@@ -49,7 +49,7 @@ export interface ShutdownEvent {
join
(
promise
:
Thenable
<
void
>
):
void
;
/**
* The reason why
Code
is shutting down.
* The reason why
the application
is shutting down.
*/
reason
:
ShutdownReason
;
}
...
...
@@ -137,17 +137,26 @@ export interface ILifecycleService {
/**
* Fired before shutdown happens. Allows listeners to veto against the
* shutdown.
* shutdown to prevent it from happening.
*
* The event carries a shutdown reason that indicates how the shutdown was triggered.
*/
readonly
on
WillShutdown
:
Event
<
Will
ShutdownEvent
>
;
readonly
on
BeforeShutdown
:
Event
<
Before
ShutdownEvent
>
;
/**
* Fired when no client is preventing the shutdown from happening. Can be used to dispose heavy resources
* like running processes. Can also be used to save UI state to storage.
* Fired when no client is preventing the shutdown from happening (from onBeforeShutdown).
* Can be used to save UI state even if that is long running through the WillShutdownEvent#join()
* method.
*
* The event carries a shutdown reason that indicates how the shutdown was triggered.
*/
readonly
onShutdown
:
Event
<
ShutdownEvent
>
;
readonly
onWillShutdown
:
Event
<
WillShutdownEvent
>
;
/**
* Fired when the shutdown is about to happen after long running shutdown operations
* have finished (from onWillShutdown). This is the right place to dispose resources.
*/
readonly
onShutdown
:
Event
<
void
>
;
/**
* Returns a promise that resolves when a certain lifecycle phase
...
...
@@ -158,6 +167,7 @@ export interface ILifecycleService {
export
const
NullLifecycleService
:
ILifecycleService
=
{
_serviceBrand
:
null
,
onBeforeShutdown
:
Event
.
None
,
onWillShutdown
:
Event
.
None
,
onShutdown
:
Event
.
None
,
phase
:
LifecyclePhase
.
Restored
,
...
...
src/vs/platform/lifecycle/electron-browser/lifecycleService.ts
浏览文件 @
94315b86
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
ILifecycleService
,
WillShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
,
handleVetos
,
LifecyclePhaseToString
,
ShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
,
BeforeShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
,
handleVetos
,
LifecyclePhaseToString
,
Will
ShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ipcRenderer
as
ipc
}
from
'
electron
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -22,11 +22,14 @@ export class LifecycleService extends Disposable implements ILifecycleService {
_serviceBrand
:
any
;
private
readonly
_onBeforeShutdown
=
this
.
_register
(
new
Emitter
<
BeforeShutdownEvent
>
());
get
onBeforeShutdown
():
Event
<
BeforeShutdownEvent
>
{
return
this
.
_onBeforeShutdown
.
event
;
}
private
readonly
_onWillShutdown
=
this
.
_register
(
new
Emitter
<
WillShutdownEvent
>
());
get
onWillShutdown
():
Event
<
WillShutdownEvent
>
{
return
this
.
_onWillShutdown
.
event
;
}
private
readonly
_onShutdown
=
this
.
_register
(
new
Emitter
<
ShutdownEvent
>
());
get
onShutdown
():
Event
<
ShutdownEvent
>
{
return
this
.
_onShutdown
.
event
;
}
private
readonly
_onShutdown
=
this
.
_register
(
new
Emitter
<
void
>
());
get
onShutdown
():
Event
<
void
>
{
return
this
.
_onShutdown
.
event
;
}
private
readonly
_startupKind
:
StartupKind
;
get
startupKind
():
StartupKind
{
return
this
.
_startupKind
;
}
...
...
@@ -77,8 +80,8 @@ export class LifecycleService extends Disposable implements ILifecycleService {
// store shutdown reason to retrieve next startup
this
.
storageService
.
store
(
LifecycleService
.
LAST_SHUTDOWN_REASON_KEY
,
JSON
.
stringify
(
reply
.
reason
),
StorageScope
.
WORKSPACE
);
// trigger on
Will
Shutdown events and veto collecting
this
.
handle
Will
Shutdown
(
reply
.
reason
).
then
(
veto
=>
{
// trigger on
Before
Shutdown events and veto collecting
this
.
handle
Before
Shutdown
(
reply
.
reason
).
then
(
veto
=>
{
if
(
veto
)
{
this
.
logService
.
trace
(
'
lifecycle: onBeforeUnload prevented via veto
'
);
this
.
storageService
.
remove
(
LifecycleService
.
LAST_SHUTDOWN_REASON_KEY
,
StorageScope
.
WORKSPACE
);
...
...
@@ -94,17 +97,22 @@ export class LifecycleService extends Disposable implements ILifecycleService {
ipc
.
on
(
'
vscode:onWillUnload
'
,
(
event
,
reply
:
{
replyChannel
:
string
,
reason
:
ShutdownReason
})
=>
{
this
.
logService
.
trace
(
`lifecycle: onWillUnload (reason:
${
reply
.
reason
}
)`
);
// trigger onShutdown events and joining
return
this
.
handleShutdown
(
reply
.
reason
).
then
(()
=>
{
// trigger onWillShutdown events and joining
return
this
.
handleWillShutdown
(
reply
.
reason
).
then
(()
=>
{
// trigger onShutdown event now that we know we will quit
this
.
_onShutdown
.
fire
();
// acknowledge to main side
ipc
.
send
(
reply
.
replyChannel
,
windowId
);
});
});
}
private
handle
Will
Shutdown
(
reason
:
ShutdownReason
):
Promise
<
boolean
>
{
private
handle
Before
Shutdown
(
reason
:
ShutdownReason
):
Promise
<
boolean
>
{
const
vetos
:
(
boolean
|
Thenable
<
boolean
>
)[]
=
[];
this
.
_on
Will
Shutdown
.
fire
({
this
.
_on
Before
Shutdown
.
fire
({
veto
(
value
)
{
vetos
.
push
(
value
);
},
...
...
@@ -117,10 +125,10 @@ export class LifecycleService extends Disposable implements ILifecycleService {
});
}
private
handleShutdown
(
reason
:
ShutdownReason
):
Thenable
<
void
>
{
private
handle
Will
Shutdown
(
reason
:
ShutdownReason
):
Thenable
<
void
>
{
const
joiners
:
Thenable
<
void
>
[]
=
[];
this
.
_onShutdown
.
fire
({
this
.
_on
Will
Shutdown
.
fire
({
join
(
promise
)
{
if
(
promise
)
{
joiners
.
push
(
promise
);
...
...
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
浏览文件 @
94315b86
...
...
@@ -53,8 +53,8 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
this
.
_toDispose
.
push
(
_webviewService
.
registerReviver
(
MainThreadWebviews
.
viewType
,
this
));
lifecycleService
.
on
Will
Shutdown
(
e
=>
{
e
.
veto
(
this
.
_on
Will
Shutdown
());
lifecycleService
.
on
Before
Shutdown
(
e
=>
{
e
.
veto
(
this
.
_on
Before
Shutdown
());
},
this
,
this
.
_toDispose
);
}
...
...
@@ -183,7 +183,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
return
this
.
_revivers
.
has
(
webview
.
state
.
viewType
)
||
!!
webview
.
reviver
;
}
private
_on
Will
Shutdown
():
boolean
{
private
_on
Before
Shutdown
():
boolean
{
this
.
_webviews
.
forEach
((
view
)
=>
{
if
(
this
.
canRevive
(
view
))
{
view
.
state
.
state
=
view
.
webviewState
;
...
...
src/vs/workbench/electron-browser/main.ts
浏览文件 @
94315b86
...
...
@@ -137,7 +137,7 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
},
mainServices
,
mainProcessClient
,
configuration
);
// Gracefully Shutdown Storage
shell
.
onShutdown
(
event
=>
{
shell
.
on
Will
Shutdown
(
event
=>
{
event
.
join
(
storageService
.
close
());
});
...
...
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
94315b86
...
...
@@ -42,7 +42,7 @@ import { ExtensionService } from 'vs/workbench/services/extensions/electron-brow
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/node/instantiationService
'
;
import
{
ILifecycleService
,
LifecyclePhase
,
ShutdownReason
,
ShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
,
LifecyclePhase
,
Will
ShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IMarkerService
}
from
'
vs/platform/markers/common/markers
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ISearchService
,
ISearchHistoryService
}
from
'
vs/platform/search/common/search
'
;
...
...
@@ -122,8 +122,8 @@ export interface ICoreServices {
*/
export
class
WorkbenchShell
extends
Disposable
{
private
readonly
_on
Shutdown
=
this
.
_register
(
new
Emitter
<
ShutdownEvent
>
());
get
on
Shutdown
():
Event
<
ShutdownEvent
>
{
return
this
.
_on
Shutdown
.
event
;
}
private
readonly
_on
WillShutdown
=
this
.
_register
(
new
Emitter
<
Will
ShutdownEvent
>
());
get
on
WillShutdown
():
Event
<
WillShutdownEvent
>
{
return
this
.
_onWill
Shutdown
.
event
;
}
private
storageService
:
DelegatingStorageService
;
private
environmentService
:
IEnvironmentService
;
...
...
@@ -428,11 +428,8 @@ export class WorkbenchShell extends Disposable {
serviceCollection
.
set
(
IDialogService
,
instantiationService
.
createInstance
(
DialogService
));
const
lifecycleService
=
instantiationService
.
createInstance
(
LifecycleService
);
this
.
_register
(
lifecycleService
.
onShutdown
(
event
=>
{
this
.
_onShutdown
.
fire
(
event
);
this
.
dispose
(
event
.
reason
);
}));
this
.
_register
(
lifecycleService
.
onWillShutdown
(
event
=>
this
.
_onWillShutdown
.
fire
(
event
)));
this
.
_register
(
lifecycleService
.
onShutdown
(()
=>
this
.
dispose
()));
serviceCollection
.
set
(
ILifecycleService
,
lifecycleService
);
this
.
lifecycleService
=
lifecycleService
;
...
...
@@ -585,12 +582,12 @@ export class WorkbenchShell extends Disposable {
this
.
workbench
.
layout
();
}
dispose
(
reason
=
ShutdownReason
.
QUIT
):
void
{
dispose
():
void
{
super
.
dispose
();
// Dispose Workbench
if
(
this
.
workbench
)
{
this
.
workbench
.
dispose
(
reason
);
this
.
workbench
.
dispose
();
}
this
.
mainProcessClient
.
dispose
();
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
94315b86
...
...
@@ -477,7 +477,7 @@ export class Workbench extends Disposable implements IPartService {
private
registerListeners
():
void
{
// Lifecycle
this
.
_register
(
this
.
lifecycleService
.
on
Will
Shutdown
(
e
=>
this
.
saveState
(
e
.
reason
)));
this
.
_register
(
this
.
lifecycleService
.
on
Before
Shutdown
(
e
=>
this
.
saveState
(
e
.
reason
)));
// Listen to visible editor changes
this
.
_register
(
this
.
editorService
.
onDidVisibleEditorsChange
(()
=>
this
.
onDidVisibleEditorsChange
()));
...
...
@@ -1142,7 +1142,7 @@ export class Workbench extends Disposable implements IPartService {
}
}
dispose
(
reason
=
ShutdownReason
.
QUIT
):
void
{
dispose
():
void
{
super
.
dispose
();
this
.
workbenchShutdown
=
true
;
...
...
src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
浏览文件 @
94315b86
...
...
@@ -529,7 +529,7 @@ class TaskService extends Disposable implements ITaskService {
this
.
updateWorkspaceTasks
();
}));
this
.
_taskRunningState
=
TASK_RUNNING_STATE
.
bindTo
(
contextKeyService
);
this
.
_register
(
lifecycleService
.
on
Will
Shutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
())));
this
.
_register
(
lifecycleService
.
on
Before
Shutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
())));
this
.
_register
(
storageService
.
onWillSaveState
(()
=>
this
.
saveState
()));
this
.
_onDidStateChange
=
this
.
_register
(
new
Emitter
());
this
.
registerCommands
();
...
...
src/vs/workbench/parts/terminal/common/terminalService.ts
浏览文件 @
94315b86
...
...
@@ -63,7 +63,7 @@ export abstract class TerminalService implements ITerminalService {
this
.
_activeTabIndex
=
0
;
this
.
_isShuttingDown
=
false
;
this
.
_findState
=
new
FindReplaceState
();
lifecycleService
.
on
WillShutdown
(
event
=>
event
.
veto
(
this
.
_onWill
Shutdown
()));
lifecycleService
.
on
BeforeShutdown
(
event
=>
event
.
veto
(
this
.
_onBefore
Shutdown
()));
lifecycleService
.
onShutdown
(()
=>
this
.
_onShutdown
());
this
.
_terminalFocusContextKey
=
KEYBINDING_CONTEXT_TERMINAL_FOCUS
.
bindTo
(
this
.
_contextKeyService
);
this
.
_findWidgetVisible
=
KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE
.
bindTo
(
this
.
_contextKeyService
);
...
...
@@ -92,7 +92,7 @@ export abstract class TerminalService implements ITerminalService {
public
abstract
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
;
public
abstract
requestExtHostProcess
(
proxy
:
ITerminalProcessExtHostProxy
,
shellLaunchConfig
:
IShellLaunchConfig
,
activeWorkspaceRootUri
:
URI
,
cols
:
number
,
rows
:
number
):
void
;
private
_on
Will
Shutdown
():
boolean
|
PromiseLike
<
boolean
>
{
private
_on
Before
Shutdown
():
boolean
|
PromiseLike
<
boolean
>
{
if
(
this
.
terminalInstances
.
length
===
0
)
{
// No terminal instances, don't veto
return
false
;
...
...
src/vs/workbench/services/extensions/electron-browser/extensionHost.ts
浏览文件 @
94315b86
...
...
@@ -124,7 +124,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
this
.
_toDispose
=
[];
this
.
_toDispose
.
push
(
this
.
_onCrashed
);
this
.
_toDispose
.
push
(
this
.
_lifecycleService
.
onWillShutdown
(
(
e
)
=>
this
.
_onWillShutdown
(
e
)));
this
.
_toDispose
.
push
(
this
.
_lifecycleService
.
onWillShutdown
(
e
=>
this
.
_onWillShutdown
(
e
)));
this
.
_toDispose
.
push
(
this
.
_lifecycleService
.
onShutdown
(
reason
=>
this
.
terminate
()));
this
.
_toDispose
.
push
(
this
.
_broadcastService
.
onBroadcast
(
b
=>
this
.
_onBroadcast
(
b
)));
...
...
@@ -563,7 +563,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
}
});
event
.
veto
(
timeout
(
100
/* wait a bit for IPC to get delivered */
).
then
(()
=>
false
));
event
.
join
(
timeout
(
100
/* wait a bit for IPC to get delivered */
));
}
}
}
...
...
src/vs/workbench/services/textfile/common/textFileService.ts
浏览文件 @
94315b86
...
...
@@ -106,7 +106,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
private
registerListeners
():
void
{
// Lifecycle
this
.
lifecycleService
.
on
Will
Shutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
(
event
.
reason
)));
this
.
lifecycleService
.
on
Before
Shutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
(
event
.
reason
)));
this
.
lifecycleService
.
onShutdown
(
this
.
dispose
,
this
);
// Files configuration changes
...
...
src/vs/workbench/services/textfile/test/textFileService.test.ts
浏览文件 @
94315b86
...
...
@@ -7,7 +7,7 @@ import * as sinon from 'sinon';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ILifecycleService
,
Will
ShutdownEvent
,
ShutdownReason
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
,
Before
ShutdownEvent
,
ShutdownReason
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
workbenchInstantiationService
,
TestLifecycleService
,
TestTextFileService
,
TestWindowsService
,
TestContextService
,
TestFileService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
toResource
}
from
'
vs/base/test/common/utils
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -37,7 +37,7 @@ class ServiceAccessor {
}
}
class
ShutdownEventImpl
implements
Will
ShutdownEvent
{
class
BeforeShutdownEventImpl
implements
Before
ShutdownEvent
{
public
value
:
boolean
|
TPromise
<
boolean
>
;
public
reason
=
ShutdownReason
.
CLOSE
;
...
...
@@ -69,7 +69,7 @@ suite('Files - TextFileService', () => {
model
=
instantiationService
.
createInstance
(
TextFileEditorModel
,
toResource
.
call
(
this
,
'
/path/file.txt
'
),
'
utf8
'
);
(
<
TextFileEditorModelManager
>
accessor
.
textFileService
.
models
).
add
(
model
.
getResource
(),
model
);
const
event
=
new
ShutdownEventImpl
();
const
event
=
new
Before
ShutdownEventImpl
();
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
const
veto
=
event
.
value
;
...
...
@@ -94,7 +94,7 @@ suite('Files - TextFileService', () => {
assert
.
equal
(
service
.
getDirty
().
length
,
1
);
const
event
=
new
ShutdownEventImpl
();
const
event
=
new
Before
ShutdownEventImpl
();
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
assert
.
ok
(
event
.
value
);
...
...
@@ -114,7 +114,7 @@ suite('Files - TextFileService', () => {
assert
.
equal
(
service
.
getDirty
().
length
,
1
);
const
event
=
new
ShutdownEventImpl
();
const
event
=
new
Before
ShutdownEventImpl
();
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
const
veto
=
event
.
value
;
...
...
@@ -145,7 +145,7 @@ suite('Files - TextFileService', () => {
assert
.
equal
(
service
.
getDirty
().
length
,
1
);
const
event
=
new
ShutdownEventImpl
();
const
event
=
new
Before
ShutdownEventImpl
();
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
return
(
<
TPromise
<
boolean
>>
event
.
value
).
then
(
veto
=>
{
...
...
@@ -450,7 +450,7 @@ suite('Files - TextFileService', () => {
assert
.
equal
(
service
.
getDirty
().
length
,
1
);
const
event
=
new
ShutdownEventImpl
();
const
event
=
new
Before
ShutdownEventImpl
();
event
.
reason
=
shutdownReason
;
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
94315b86
...
...
@@ -24,7 +24,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import
{
IEditorOptions
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IWorkspaceContextService
,
IWorkspace
as
IWorkbenchWorkspace
,
WorkbenchState
,
IWorkspaceFolder
,
IWorkspaceFoldersChangeEvent
,
Workspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ILifecycleService
,
WillShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
,
ShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
,
BeforeShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
,
Will
ShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
TextFileService
}
from
'
vs/workbench/services/textfile/common/textFileService
'
;
import
{
FileOperationEvent
,
IFileService
,
IResolveContentOptions
,
FileOperationError
,
IFileStat
,
IResolveFileResult
,
FileChangesEvent
,
IResolveFileOptions
,
IContent
,
IUpdateContentOptions
,
IStreamContent
,
ICreateFileOptions
,
ITextSnapshot
,
IResourceEncodings
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -1144,29 +1144,34 @@ export class TestLifecycleService implements ILifecycleService {
public
phase
:
LifecyclePhase
;
public
startupKind
:
StartupKind
;
private
_onBeforeShutdown
=
new
Emitter
<
BeforeShutdownEvent
>
();
private
_onWillShutdown
=
new
Emitter
<
WillShutdownEvent
>
();
private
_onShutdown
=
new
Emitter
<
ShutdownEvent
>
();
private
_onShutdown
=
new
Emitter
<
void
>
();
when
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
public
fireShutdown
(
reason
=
ShutdownReason
.
QUIT
):
void
{
this
.
_onShutdown
.
fire
({
this
.
_on
Will
Shutdown
.
fire
({
join
:
()
=>
{
},
reason
});
}
public
fireWillShutdown
(
event
:
WillShutdownEvent
):
void
{
this
.
_onWillShutdown
.
fire
(
event
);
public
fireWillShutdown
(
event
:
BeforeShutdownEvent
):
void
{
this
.
_onBeforeShutdown
.
fire
(
event
);
}
public
get
onBeforeShutdown
():
Event
<
BeforeShutdownEvent
>
{
return
this
.
_onBeforeShutdown
.
event
;
}
public
get
onWillShutdown
():
Event
<
WillShutdownEvent
>
{
return
this
.
_onWillShutdown
.
event
;
}
public
get
onShutdown
():
Event
<
ShutdownEvent
>
{
public
get
onShutdown
():
Event
<
void
>
{
return
this
.
_onShutdown
.
event
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录