Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
5bb2cb84
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,发现更多精彩内容 >>
提交
5bb2cb84
编写于
11月 04, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable all window restore on quit
Part of #13305
上级
8ed9c07f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
31 addition
and
14 deletion
+31
-14
src/vs/code/electron-main/lifecycle.ts
src/vs/code/electron-main/lifecycle.ts
+1
-1
src/vs/platform/lifecycle/common/lifecycle.ts
src/vs/platform/lifecycle/common/lifecycle.ts
+7
-0
src/vs/workbench/services/backup/common/backup.ts
src/vs/workbench/services/backup/common/backup.ts
+1
-1
src/vs/workbench/services/backup/node/backupService.ts
src/vs/workbench/services/backup/node/backupService.ts
+4
-3
src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts
...h/services/lifecycle/electron-browser/lifecycleService.ts
+14
-6
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+3
-3
src/vs/workbench/services/textfile/test/textFileService.test.ts
.../workbench/services/textfile/test/textFileService.test.ts
+1
-0
未找到文件。
src/vs/code/electron-main/lifecycle.ts
浏览文件 @
5bb2cb84
...
...
@@ -185,7 +185,7 @@ export class LifecycleService implements ILifecycleService {
c
(
true
);
// veto
});
vscodeWindow
.
send
(
'
vscode:beforeUnload
'
,
{
okChannel
:
oneTimeOkEvent
,
cancelChannel
:
oneTimeCancelEvent
});
vscodeWindow
.
send
(
'
vscode:beforeUnload
'
,
{
okChannel
Reply
:
oneTimeOkEvent
,
cancelChannelReply
:
oneTimeCancelEvent
,
quitRequested
:
this
.
quitRequested
});
});
}
...
...
src/vs/platform/lifecycle/common/lifecycle.ts
浏览文件 @
5bb2cb84
...
...
@@ -22,6 +22,7 @@ export const ILifecycleService = createDecorator<ILifecycleService>('lifecycleSe
export
interface
ShutdownEvent
{
veto
(
value
:
boolean
|
TPromise
<
boolean
>
):
void
;
quitRequested
:
boolean
;
}
/**
...
...
@@ -38,6 +39,12 @@ export interface ILifecycleService {
*/
willShutdown
:
boolean
;
/**
* A flag indications if the application is in the process of quitting all windows. This will be
* set before the onWillShutdown event is fired and reverted to false afterwards.
*/
quitRequested
:
boolean
;
/**
* Fired before shutdown happens. Allows listeners to veto against the
* shutdown.
...
...
src/vs/workbench/services/backup/common/backup.ts
浏览文件 @
5bb2cb84
...
...
@@ -22,7 +22,7 @@ export interface IBackupService {
_serviceBrand
:
any
;
isHotExitEnabled
:
boolean
;
backupBeforeShutdown
(
dirtyToBackup
:
Uri
[],
textFileEditorModelManager
:
ITextFileEditorModelManager
,
confirmCallback
:
()
=>
boolean
|
TPromise
<
boolean
>
):
boolean
|
TPromise
<
boolean
>
;
backupBeforeShutdown
(
dirtyToBackup
:
Uri
[],
textFileEditorModelManager
:
ITextFileEditorModelManager
,
quitRequested
:
boolean
,
confirmCallback
:
()
=>
boolean
|
TPromise
<
boolean
>
):
boolean
|
TPromise
<
boolean
>
;
cleanupBackupsBeforeShutdown
():
boolean
|
TPromise
<
boolean
>
;
doBackup
(
resource
:
Uri
,
content
:
string
,
immediate
?:
boolean
):
TPromise
<
void
>
;
...
...
src/vs/workbench/services/backup/node/backupService.ts
浏览文件 @
5bb2cb84
...
...
@@ -129,15 +129,16 @@ export class BackupService implements IBackupService {
return
this
.
configuredHotExit
&&
this
.
contextService
.
getWorkspace
()
&&
!
platform
.
isMacintosh
;
}
public
backupBeforeShutdown
(
dirtyToBackup
:
Uri
[],
textFileEditorModelManager
:
ITextFileEditorModelManager
,
confirmCallback
:
()
=>
boolean
|
TPromise
<
boolean
>
):
boolean
|
TPromise
<
boolean
>
{
public
backupBeforeShutdown
(
dirtyToBackup
:
Uri
[],
textFileEditorModelManager
:
ITextFileEditorModelManager
,
quitRequested
:
boolean
,
confirmCallback
:
()
=>
boolean
|
TPromise
<
boolean
>
):
boolean
|
TPromise
<
boolean
>
{
// If there are no dirty files, clean up and exit
if
(
dirtyToBackup
.
length
===
0
)
{
return
this
.
cleanupBackupsBeforeShutdown
();
}
return
this
.
backupFileService
.
getWorkspaceBackupPaths
().
then
(
workspaceBackupPaths
=>
{
// Only remove the workspace from the backup service if it's not the last one or it's not dirty
if
(
workspaceBackupPaths
.
length
>
1
)
{
// Only remove the workspace's backups if it's not the last one or it's not dirty. The one exception to this
// is if quit (all windows) was requested then all windows should be backed up and restored on next launch..
if
(
!
quitRequested
&&
workspaceBackupPaths
.
length
>
1
)
{
return
confirmCallback
();
// confirm save
}
...
...
src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts
浏览文件 @
5bb2cb84
...
...
@@ -21,6 +21,7 @@ export class LifecycleService implements ILifecycleService {
private
_onShutdown
=
new
Emitter
<
void
>
();
private
_willShutdown
:
boolean
;
private
_quitRequested
:
boolean
;
constructor
(
@
IMessageService
private
messageService
:
IMessageService
,
...
...
@@ -33,6 +34,10 @@ export class LifecycleService implements ILifecycleService {
return
this
.
_willShutdown
;
}
public
get
quitRequested
():
boolean
{
return
this
.
_quitRequested
;
}
public
get
onWillShutdown
():
Event
<
ShutdownEvent
>
{
return
this
.
_onWillShutdown
.
event
;
}
...
...
@@ -45,29 +50,32 @@ export class LifecycleService implements ILifecycleService {
const
windowId
=
this
.
windowService
.
getWindowId
();
// Main side indicates that window is about to unload, check for vetos
ipc
.
on
(
'
vscode:beforeUnload
'
,
(
event
,
reply
:
{
okChannel
:
string
,
cancelChannel
:
string
})
=>
{
ipc
.
on
(
'
vscode:beforeUnload
'
,
(
event
,
args
:
{
okChannelReply
:
string
,
cancelChannelReply
:
string
,
quitRequested
:
boolean
})
=>
{
this
.
_willShutdown
=
true
;
this
.
_quitRequested
=
args
.
quitRequested
;
// trigger onWillShutdown events and veto collecting
this
.
onBeforeUnload
().
done
(
veto
=>
{
this
.
onBeforeUnload
(
args
.
quitRequested
).
done
(
veto
=>
{
this
.
_quitRequested
=
false
;
if
(
veto
)
{
this
.
_willShutdown
=
false
;
// reset this flag since the shutdown has been vetoed!
ipc
.
send
(
reply
.
cancelChannel
,
windowId
);
ipc
.
send
(
args
.
cancelChannelReply
,
windowId
);
}
else
{
this
.
_onShutdown
.
fire
();
ipc
.
send
(
reply
.
okChannel
,
windowId
);
ipc
.
send
(
args
.
okChannelReply
,
windowId
);
}
});
});
}
private
onBeforeUnload
():
TPromise
<
boolean
>
{
private
onBeforeUnload
(
quitRequested
:
boolean
):
TPromise
<
boolean
>
{
const
vetos
:
(
boolean
|
TPromise
<
boolean
>
)[]
=
[];
this
.
_onWillShutdown
.
fire
({
veto
(
value
)
{
vetos
.
push
(
value
);
}
},
quitRequested
});
if
(
vetos
.
length
===
0
)
{
...
...
src/vs/workbench/services/textfile/browser/textFileService.ts
浏览文件 @
5bb2cb84
...
...
@@ -101,7 +101,7 @@ export abstract class TextFileService implements ITextFileService {
private
registerListeners
():
void
{
// Lifecycle
this
.
lifecycleService
.
onWillShutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
()));
this
.
lifecycleService
.
onWillShutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
(
event
.
quitRequested
)));
this
.
lifecycleService
.
onShutdown
(
this
.
dispose
,
this
);
// Configuration changes
...
...
@@ -113,9 +113,9 @@ export abstract class TextFileService implements ITextFileService {
this
.
toUnbind
.
push
(
this
.
editorGroupService
.
onEditorsChanged
(()
=>
this
.
onEditorFocusChanged
()));
}
private
beforeShutdown
():
boolean
|
TPromise
<
boolean
>
{
private
beforeShutdown
(
quitRequested
:
boolean
):
boolean
|
TPromise
<
boolean
>
{
if
(
this
.
backupService
.
isHotExitEnabled
)
{
return
this
.
backupService
.
backupBeforeShutdown
(
this
.
getDirty
(),
this
.
models
,
this
.
confirmBeforeShutdown
.
bind
(
this
));
return
this
.
backupService
.
backupBeforeShutdown
(
this
.
getDirty
(),
this
.
models
,
quitRequested
,
this
.
confirmBeforeShutdown
.
bind
(
this
));
}
// Dirty files need treatment on shutdown
...
...
src/vs/workbench/services/textfile/test/textFileService.test.ts
浏览文件 @
5bb2cb84
...
...
@@ -28,6 +28,7 @@ class ServiceAccessor {
class
ShutdownEventImpl
implements
ShutdownEvent
{
public
value
:
boolean
|
TPromise
<
boolean
>
;
public
quitRequested
:
boolean
=
false
;
veto
(
value
:
boolean
|
TPromise
<
boolean
>
):
void
{
this
.
value
=
value
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录