Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
731e2b95
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,发现更多精彩内容 >>
提交
731e2b95
编写于
12月 09, 2019
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert rootPath changes
This reverts commits
a416c77e
,
5bc80f3e
,
0403a108
上级
e3090616
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
93 addition
and
15 deletion
+93
-15
extensions/vscode-api-tests/src/workspace-tests/workspace.test.ts
...ns/vscode-api-tests/src/workspace-tests/workspace.test.ts
+1
-1
src/vs/workbench/api/common/extHostWorkspace.ts
src/vs/workbench/api/common/extHostWorkspace.ts
+0
-5
src/vs/workbench/contrib/relauncher/browser/relauncher.contribution.ts
...nch/contrib/relauncher/browser/relauncher.contribution.ts
+91
-8
src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts
...kbench/test/electron-browser/api/extHostWorkspace.test.ts
+1
-1
未找到文件。
extensions/vscode-api-tests/src/workspace-tests/workspace.test.ts
浏览文件 @
731e2b95
...
...
@@ -13,7 +13,7 @@ suite('workspace-namespace', () => {
teardown
(
closeAllEditors
);
test
(
'
rootPath
'
,
()
=>
{
assert
.
equal
(
vscode
.
workspace
.
rootPath
,
undefined
);
assert
.
ok
(
pathEquals
(
vscode
.
workspace
.
rootPath
!
,
join
(
__dirname
,
'
../../testWorkspace
'
))
);
});
test
(
'
workspaceFile
'
,
()
=>
{
...
...
src/vs/workbench/api/common/extHostWorkspace.ts
浏览文件 @
731e2b95
...
...
@@ -339,11 +339,6 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
if
(
folders
.
length
===
0
)
{
return
undefined
;
}
if
(
folders
.
length
>
1
)
{
return
undefined
;
}
// #54483 @Joh Why are we still using fsPath?
return
folders
[
0
].
uri
.
fsPath
;
}
...
...
src/vs/workbench/contrib/relauncher/browser/relauncher.contribution.ts
浏览文件 @
731e2b95
...
...
@@ -3,17 +3,23 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
isMacintosh
,
isNative
}
from
'
vs/base/common/platform
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/productService
'
;
import
{
IDisposable
,
dispose
,
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchContributionsRegistry
,
IWorkbenchContribution
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IWindowsConfiguration
}
from
'
vs/platform/windows/common/windows
'
;
import
{
Extensions
as
WorkbenchExtensions
,
IWorkbenchContribution
,
IWorkbenchContributionsRegistry
}
from
'
vs/workbench/common/contributions
'
;
import
{
IHostService
}
from
'
vs/workbench/services/host/browser/host
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IWorkspaceContextService
,
WorkbenchState
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
isEqual
}
from
'
vs/base/common/resources
'
;
import
{
isMacintosh
,
isNative
}
from
'
vs/base/common/platform
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/productService
'
;
interface
IConfiguration
extends
IWindowsConfiguration
{
update
:
{
mode
:
string
;
};
...
...
@@ -126,5 +132,82 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
}
}
export
class
WorkspaceChangeExtHostRelauncher
extends
Disposable
implements
IWorkbenchContribution
{
private
firstFolderResource
?:
URI
;
private
extensionHostRestarter
:
RunOnceScheduler
;
private
onDidChangeWorkspaceFoldersUnbind
:
IDisposable
|
undefined
;
constructor
(
@
IWorkspaceContextService
private
readonly
contextService
:
IWorkspaceContextService
,
@
IExtensionService
extensionService
:
IExtensionService
,
@
IHostService
hostService
:
IHostService
,
@
IWorkbenchEnvironmentService
environmentService
:
IWorkbenchEnvironmentService
)
{
super
();
this
.
extensionHostRestarter
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
{
if
(
!!
environmentService
.
extensionTestsLocationURI
)
{
return
;
// no restart when in tests: see https://github.com/Microsoft/vscode/issues/66936
}
if
(
environmentService
.
configuration
.
remoteAuthority
)
{
hostService
.
reload
();
// TODO@aeschli, workaround
}
else
if
(
isNative
)
{
extensionService
.
restartExtensionHost
();
}
},
10
));
this
.
contextService
.
getCompleteWorkspace
()
.
then
(
workspace
=>
{
this
.
firstFolderResource
=
workspace
.
folders
.
length
>
0
?
workspace
.
folders
[
0
].
uri
:
undefined
;
this
.
handleWorkbenchState
();
this
.
_register
(
this
.
contextService
.
onDidChangeWorkbenchState
(()
=>
setTimeout
(()
=>
this
.
handleWorkbenchState
())));
});
this
.
_register
(
toDisposable
(()
=>
{
if
(
this
.
onDidChangeWorkspaceFoldersUnbind
)
{
this
.
onDidChangeWorkspaceFoldersUnbind
.
dispose
();
}
}));
}
private
handleWorkbenchState
():
void
{
// React to folder changes when we are in workspace state
if
(
this
.
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
WORKSPACE
)
{
// Update our known first folder path if we entered workspace
const
workspace
=
this
.
contextService
.
getWorkspace
();
this
.
firstFolderResource
=
workspace
.
folders
.
length
>
0
?
workspace
.
folders
[
0
].
uri
:
undefined
;
// Install workspace folder listener
if
(
!
this
.
onDidChangeWorkspaceFoldersUnbind
)
{
this
.
onDidChangeWorkspaceFoldersUnbind
=
this
.
contextService
.
onDidChangeWorkspaceFolders
(()
=>
this
.
onDidChangeWorkspaceFolders
());
}
}
// Ignore the workspace folder changes in EMPTY or FOLDER state
else
{
dispose
(
this
.
onDidChangeWorkspaceFoldersUnbind
);
this
.
onDidChangeWorkspaceFoldersUnbind
=
undefined
;
}
}
private
onDidChangeWorkspaceFolders
():
void
{
const
workspace
=
this
.
contextService
.
getWorkspace
();
// Restart extension host if first root folder changed (impact on deprecated workspace.rootPath API)
const
newFirstFolderResource
=
workspace
.
folders
.
length
>
0
?
workspace
.
folders
[
0
].
uri
:
undefined
;
if
(
!
isEqual
(
this
.
firstFolderResource
,
newFirstFolderResource
))
{
this
.
firstFolderResource
=
newFirstFolderResource
;
this
.
extensionHostRestarter
.
schedule
();
// buffer calls to extension host restart
}
}
}
const
workbenchRegistry
=
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
);
workbenchRegistry
.
registerWorkbenchContribution
(
SettingsChangeRelauncher
,
LifecyclePhase
.
Restored
);
workbenchRegistry
.
registerWorkbenchContribution
(
WorkspaceChangeExtHostRelauncher
,
LifecyclePhase
.
Restored
);
src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts
浏览文件 @
731e2b95
...
...
@@ -120,7 +120,7 @@ suite('ExtHostWorkspace', function () {
assert
.
equal
(
ws
.
getPath
(),
undefined
);
ws
=
createExtHostWorkspace
(
new
TestRPCProtocol
(),
{
id
:
'
foo
'
,
name
:
'
Test
'
,
folders
:
[
aWorkspaceFolderData
(
URI
.
file
(
'
Folder
'
),
0
),
aWorkspaceFolderData
(
URI
.
file
(
'
Another/Folder
'
),
1
)]
},
new
NullLogService
());
assert
.
equal
(
ws
.
getPath
()
,
undefined
);
assert
.
equal
(
ws
.
getPath
()
!
.
replace
(
/
\\
/g
,
'
/
'
),
'
/Folder
'
);
ws
=
createExtHostWorkspace
(
new
TestRPCProtocol
(),
{
id
:
'
foo
'
,
name
:
'
Test
'
,
folders
:
[
aWorkspaceFolderData
(
URI
.
file
(
'
/Folder
'
),
0
)]
},
new
NullLogService
());
assert
.
equal
(
ws
.
getPath
()
!
.
replace
(
/
\\
/g
,
'
/
'
),
'
/Folder
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录