Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
64db1a9f
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,发现更多精彩内容 >>
提交
64db1a9f
编写于
9月 18, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
restart extension host based on workbench state change (for #32945)
上级
0943cc3d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
28 deletion
+22
-28
src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts
...ts/relauncher/electron-browser/relauncher.contribution.ts
+22
-28
未找到文件。
src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts
浏览文件 @
64db1a9f
...
...
@@ -14,8 +14,9 @@ import { IWindowsService, IWindowService, IWindowsConfiguration } from 'vs/platf
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
,
WorkbenchState
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
interface
IConfiguration
extends
IWindowsConfiguration
{
update
:
{
channel
:
string
;
};
...
...
@@ -30,8 +31,10 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
private
nativeTabs
:
boolean
;
private
updateChannel
:
string
;
private
enableCrashReporter
:
boolean
;
private
foldersCount
:
number
;
private
firstFolderPath
:
string
;
private
workbenchState
:
WorkbenchState
;
private
extensionHostRestarter
:
RunOnceScheduler
;
constructor
(
@
IWindowsService
private
windowsService
:
IWindowsService
,
...
...
@@ -44,8 +47,9 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
@
IExtensionService
private
extensionService
:
IExtensionService
)
{
const
workspace
=
this
.
contextService
.
getWorkspace
();
this
.
foldersCount
=
workspace
.
folders
.
length
;
this
.
firstFolderPath
=
workspace
.
folders
.
length
>
0
?
workspace
.
folders
[
0
].
uri
.
fsPath
:
void
0
;
this
.
workbenchState
=
this
.
contextService
.
getWorkbenchState
();
this
.
extensionHostRestarter
=
new
RunOnceScheduler
(()
=>
this
.
extensionService
.
restartExtensionHost
(),
10
);
this
.
onConfigurationChange
(
configurationService
.
getConfiguration
<
IConfiguration
>
(),
false
);
...
...
@@ -55,6 +59,7 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
private
registerListeners
():
void
{
this
.
toDispose
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationChange
(
this
.
configurationService
.
getConfiguration
<
IConfiguration
>
(),
true
)));
this
.
toDispose
.
push
(
this
.
contextService
.
onDidChangeWorkspaceFolders
(()
=>
this
.
onDidChangeWorkspaceFolders
()));
this
.
toDispose
.
push
(
this
.
contextService
.
onDidChangeWorkbenchState
(()
=>
this
.
onDidChangeWorkbenchState
()));
}
private
onConfigurationChange
(
config
:
IConfiguration
,
notify
:
boolean
):
void
{
...
...
@@ -98,39 +103,28 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
private
onDidChangeWorkspaceFolders
():
void
{
const
workspace
=
this
.
contextService
.
getWorkspace
();
const
newFoldersCount
=
workspace
.
folders
.
length
;
// Restart extension host if first root folder changed (impact on deprecated workspace.rootPath API)
const
newFirstFolderPath
=
workspace
.
folders
.
length
>
0
?
workspace
.
folders
[
0
].
uri
.
fsPath
:
void
0
;
if
(
this
.
firstFolderPath
!==
newFirstFolderPath
)
{
this
.
firstFolderPath
=
newFirstFolderPath
;
let
reloadWindow
=
false
;
let
reloadExtensionHost
=
false
;
if
(
this
.
foldersCount
===
0
&&
newFoldersCount
>
0
)
{
reloadWindow
=
true
;
// transition: from 0 folders to 1+
}
else
if
(
this
.
foldersCount
>
0
&&
newFoldersCount
===
0
)
{
reloadWindow
=
true
;
// transition: from 1+ folders to 0
this
.
doRestartExtensionHost
();
}
}
if
(
this
.
firstFolderPath
!==
newFirstFolderPath
)
{
reloadExtensionHost
=
true
;
// first root folder changed (impact on deprecated workspace.rootPath API)
}
private
onDidChangeWorkbenchState
():
void
{
this
.
foldersCount
=
newFoldersCount
;
this
.
firstFolderPath
=
newFirstFolderPath
;
// Restart extension host if the workbench state changes (impact on extension storage)
const
newWorkbenchState
=
this
.
contextService
.
getWorkbenchState
();
if
(
newWorkbenchState
!==
this
.
workbenchState
)
{
this
.
workbenchState
=
newWorkbenchState
;
// Reload window if this is needed
if
(
reloadWindow
)
{
this
.
doConfirm
(
localize
(
'
relaunchWorkspaceMessage
'
,
"
This workspace change requires a reload of our extension system.
"
),
void
0
,
localize
(
'
reload
'
,
"
Reload
"
),
()
=>
this
.
windowService
.
reloadWindow
()
);
this
.
doRestartExtensionHost
();
}
}
// Reload extension host if this is needed
else
if
(
reloadExtensionHost
)
{
this
.
extensionService
.
restartExtensionHost
();
}
private
doRestartExtensionHost
():
void
{
this
.
extensionHostRestarter
.
schedule
();
// buffer calls to extension host restart
}
private
doConfirm
(
message
:
string
,
detail
:
string
,
primaryButton
:
string
,
confirmed
:
()
=>
void
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录