Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8d53e233
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,体验更适合开发者的 AI 搜索 >>
提交
8d53e233
编写于
4月 15, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - adopt remote path user home
上级
53bbba0b
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
173 addition
and
104 deletion
+173
-104
src/vs/platform/environment/common/environment.ts
src/vs/platform/environment/common/environment.ts
+4
-10
src/vs/workbench/contrib/debug/browser/linkDetector.ts
src/vs/workbench/contrib/debug/browser/linkDetector.ts
+1
-1
src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts
src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts
+1
-1
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
...s/workbench/contrib/search/browser/anythingQuickAccess.ts
+2
-1
src/vs/workbench/contrib/search/common/queryBuilder.ts
src/vs/workbench/contrib/search/common/queryBuilder.ts
+4
-8
src/vs/workbench/contrib/search/test/browser/queryBuilder.test.ts
...orkbench/contrib/search/test/browser/queryBuilder.test.ts
+1
-1
src/vs/workbench/contrib/search/test/electron-browser/queryBuilder.test.ts
...contrib/search/test/electron-browser/queryBuilder.test.ts
+2
-3
src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts
...kbench/contrib/terminal/browser/terminalProcessManager.ts
+2
-2
src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts
...b/terminal/test/browser/links/terminalLinkManager.test.ts
+1
-1
src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts
...eybinding/test/electron-browser/keybindingEditing.test.ts
+3
-1
src/vs/workbench/services/label/common/labelService.ts
src/vs/workbench/services/label/common/labelService.ts
+2
-2
src/vs/workbench/services/label/test/browser/label.test.ts
src/vs/workbench/services/label/test/browser/label.test.ts
+1
-25
src/vs/workbench/services/label/test/electron-browser/label.test.ts
...kbench/services/label/test/electron-browser/label.test.ts
+43
-0
src/vs/workbench/services/path/browser/remotePathService.ts
src/vs/workbench/services/path/browser/remotePathService.ts
+29
-0
src/vs/workbench/services/path/common/remotePathService.ts
src/vs/workbench/services/path/common/remotePathService.ts
+33
-40
src/vs/workbench/services/path/electron-browser/remotePathService.ts
...bench/services/path/electron-browser/remotePathService.ts
+22
-0
src/vs/workbench/test/browser/workbenchTestServices.ts
src/vs/workbench/test/browser/workbenchTestServices.ts
+8
-5
src/vs/workbench/test/electron-browser/workbenchTestServices.ts
.../workbench/test/electron-browser/workbenchTestServices.ts
+12
-2
src/vs/workbench/workbench.common.main.ts
src/vs/workbench/workbench.common.main.ts
+0
-1
src/vs/workbench/workbench.desktop.main.ts
src/vs/workbench/workbench.desktop.main.ts
+1
-0
src/vs/workbench/workbench.web.main.ts
src/vs/workbench/workbench.web.main.ts
+1
-0
未找到文件。
src/vs/platform/environment/common/environment.ts
浏览文件 @
8d53e233
...
...
@@ -36,6 +36,10 @@ export interface IEnvironmentService {
argvResource
:
URI
;
snippetsHome
:
URI
;
// --- data paths
backupHome
:
URI
;
untitledWorkspacesHome
:
URI
;
// --- settings sync
userDataSyncLogResource
:
URI
;
userDataSyncHome
:
URI
;
...
...
@@ -56,20 +60,10 @@ export interface IEnvironmentService {
verbose
:
boolean
;
isBuilt
:
boolean
;
// --- data paths
backupHome
:
URI
;
untitledWorkspacesHome
:
URI
;
// --- misc
disableTelemetry
:
boolean
;
serviceMachineIdResource
:
URI
;
/**
* @deprecated use IRemotePathService#userHome instead (https://github.com/microsoft/vscode/issues/94506)
*/
userHome
?:
URI
;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NOTE: DO NOT ADD ANY OTHER PROPERTY INTO THE COLLECTION HERE
// UNLESS THIS PROPERTY IS SUPPORTED BOTH IN WEB AND DESKTOP!!!!
...
...
src/vs/workbench/contrib/debug/browser/linkDetector.ts
浏览文件 @
8d53e233
...
...
@@ -120,7 +120,7 @@ export class LinkDetector {
}
if
(
path
[
0
]
===
'
~
'
)
{
const
userHome
=
this
.
remotePathService
.
userHomeSync
;
const
userHome
=
this
.
remotePathService
.
resolvedUserHome
;
if
(
userHome
)
{
path
=
osPath
.
join
(
userHome
.
fsPath
,
path
.
substring
(
1
));
}
...
...
src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts
浏览文件 @
8d53e233
...
...
@@ -347,7 +347,7 @@ class SessionTreeItem extends BaseTreeItem {
}
else
{
// on unix try to tildify absolute paths
path
=
normalize
(
path
);
const
userHome
=
this
.
_remotePathService
.
userHomeSync
;
const
userHome
=
this
.
_remotePathService
.
resolvedUserHome
;
if
(
userHome
&&
!
isWindows
)
{
path
=
tildify
(
path
,
userHome
.
fsPath
);
}
...
...
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
浏览文件 @
8d53e233
...
...
@@ -631,7 +631,8 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
return
;
}
const
detildifiedQuery
=
untildify
(
query
.
original
,
(
await
this
.
remotePathService
.
userHome
).
path
);
const
userHome
=
await
this
.
remotePathService
.
userHome
;
const
detildifiedQuery
=
untildify
(
query
.
original
,
userHome
.
scheme
===
Schemas
.
file
?
userHome
.
fsPath
:
userHome
.
path
);
if
(
token
.
isCancellationRequested
)
{
return
;
}
...
...
src/vs/workbench/contrib/search/common/queryBuilder.ts
浏览文件 @
8d53e233
...
...
@@ -12,7 +12,7 @@ import { Schemas } from 'vs/base/common/network';
import
*
as
path
from
'
vs/base/common/path
'
;
import
{
isEqual
}
from
'
vs/base/common/resources
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
URI
as
uri
,
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
as
uri
}
from
'
vs/base/common/uri
'
;
import
{
isMultilineRegexSource
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -84,13 +84,8 @@ export class QueryBuilder {
@
IWorkspaceContextService
private
readonly
workspaceContextService
:
IWorkspaceContextService
,
@
IRemotePathService
private
readonly
remotePathService
:
IRemotePathService
)
{
this
.
remotePathService
.
userHome
.
then
(
userHome
=>
{
this
.
_userHome
=
userHome
;
});
}
private
_userHome
:
URI
|
undefined
;
text
(
contentPattern
:
IPatternInfo
,
folderResources
?:
uri
[],
options
:
ITextQueryBuilderOptions
=
{}):
ITextQuery
{
contentPattern
=
this
.
getContentPattern
(
contentPattern
,
options
);
const
searchConfig
=
this
.
configurationService
.
getValue
<
ISearchConfiguration
>
();
...
...
@@ -244,8 +239,9 @@ export class QueryBuilder {
const
segments
=
splitGlobPattern
(
pattern
)
.
map
(
segment
=>
{
if
(
this
.
_userHome
)
{
return
untildify
(
segment
,
this
.
_userHome
.
fsPath
);
const
userHome
=
this
.
remotePathService
.
resolvedUserHome
;
if
(
userHome
)
{
return
untildify
(
segment
,
userHome
.
scheme
===
Schemas
.
file
?
userHome
.
fsPath
:
userHome
.
path
);
}
return
segment
;
...
...
src/vs/workbench/contrib/search/test/browser/queryBuilder.test.ts
浏览文件 @
8d53e233
...
...
@@ -50,7 +50,7 @@ suite('QueryBuilder', () => {
instantiationService
.
stub
(
IWorkspaceContextService
,
mockContextService
);
instantiationService
.
stub
(
IEnvironmentService
,
TestEnvironmentService
);
instantiationService
.
stub
(
IRemotePathService
,
new
TestRemotePathService
(
TestEnvironmentService
));
instantiationService
.
stub
(
IRemotePathService
,
new
TestRemotePathService
());
queryBuilder
=
instantiationService
.
createInstance
(
QueryBuilder
);
});
...
...
src/vs/workbench/contrib/search/test/electron-browser/queryBuilder.test.ts
浏览文件 @
8d53e233
...
...
@@ -8,10 +8,9 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
TestInstantiationService
}
from
'
vs/platform/instantiation/test/common/instantiationServiceMock
'
;
import
{
IWorkspaceContextService
,
toWorkspaceFolder
,
Workspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ISearchPathsInfo
,
QueryBuilder
}
from
'
vs/workbench/contrib/search/common/queryBuilder
'
;
import
{
TestEnvironmentService
}
from
'
vs/workbench/test/electron-browser/workbenchTestServices
'
;
import
{
TestEnvironmentService
,
TestNativeRemotePathService
}
from
'
vs/workbench/test/electron-browser/workbenchTestServices
'
;
import
{
assertEqualSearchPathResults
,
getUri
,
patternsToIExpression
,
globalGlob
,
fixPath
}
from
'
vs/workbench/contrib/search/test/browser/queryBuilder.test
'
;
import
{
TestContextService
}
from
'
vs/workbench/test/common/workbenchTestServices
'
;
import
{
TestRemotePathService
}
from
'
vs/workbench/test/browser/workbenchTestServices
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
const
DEFAULT_EDITOR_CONFIG
=
{};
...
...
@@ -41,7 +40,7 @@ suite('QueryBuilder', () => {
instantiationService
.
stub
(
IWorkspaceContextService
,
mockContextService
);
instantiationService
.
stub
(
IEnvironmentService
,
TestEnvironmentService
);
instantiationService
.
stub
(
IRemotePathService
,
new
TestRemotePathService
(
TestEnvironmentService
));
instantiationService
.
stub
(
IRemotePathService
,
new
Test
Native
RemotePathService
(
TestEnvironmentService
));
queryBuilder
=
instantiationService
.
createInstance
(
QueryBuilder
);
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
5
));
// Wait for RemotePathService.userHome to resolve
...
...
src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts
浏览文件 @
8d53e233
...
...
@@ -135,9 +135,9 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
const
hasRemoteAuthority
=
!!
this
.
remoteAuthority
;
let
launchRemotely
=
hasRemoteAuthority
||
forceExtHostProcess
;
//
userHomeSync
is needed here as remote resolvers can launch local terminals before
//
resolvedUserHome
is needed here as remote resolvers can launch local terminals before
// they're connected to the remote.
this
.
userHome
=
this
.
_remotePathService
.
userHomeSync
?.
fsPath
;
this
.
userHome
=
this
.
_remotePathService
.
resolvedUserHome
?.
fsPath
;
this
.
os
=
platform
.
OS
;
if
(
launchRemotely
)
{
const
userHomeUri
=
await
this
.
_remotePathService
.
userHome
;
...
...
src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts
浏览文件 @
8d53e233
...
...
@@ -93,7 +93,7 @@ suite('Workbench - TerminalLinkHandler', () => {
setup
(()
=>
{
instantiationService
=
new
TestInstantiationService
();
instantiationService
.
stub
(
IEnvironmentService
,
TestEnvironmentService
);
instantiationService
.
stub
(
IRemotePathService
,
new
TestRemotePathService
(
TestEnvironmentService
));
instantiationService
.
stub
(
IRemotePathService
,
new
TestRemotePathService
());
});
suite
(
'
localLinkRegex
'
,
()
=>
{
...
...
src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts
浏览文件 @
8d53e233
...
...
@@ -38,7 +38,7 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
import
{
KeybindingsEditingService
}
from
'
vs/workbench/services/keybinding/common/keybindingEditing
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
TextModelResolverService
}
from
'
vs/workbench/services/textmodelResolver/common/textModelResolverService
'
;
import
{
TestBackupFileService
,
TestEditorGroupsService
,
TestEditorService
,
TestLifecycleService
}
from
'
vs/workbench/test/browser/workbenchTestServices
'
;
import
{
TestBackupFileService
,
TestEditorGroupsService
,
TestEditorService
,
TestLifecycleService
,
TestRemotePathService
}
from
'
vs/workbench/test/browser/workbenchTestServices
'
;
import
{
FileService
}
from
'
vs/platform/files/common/fileService
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
DiskFileSystemProvider
}
from
'
vs/platform/files/node/diskFileSystemProvider
'
;
...
...
@@ -57,6 +57,7 @@ import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
import
{
TestTextResourcePropertiesService
,
TestContextService
,
TestWorkingCopyService
}
from
'
vs/workbench/test/common/workbenchTestServices
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
TestThemeService
}
from
'
vs/platform/theme/test/common/testThemeService
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
class
TestEnvironmentService
extends
NativeWorkbenchEnvironmentService
{
...
...
@@ -93,6 +94,7 @@ suite('KeybindingsEditing', () => {
configService
.
setUserConfiguration
(
'
files
'
,
{
'
eol
'
:
'
\n
'
});
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
instantiationService
.
stub
(
IRemotePathService
,
new
TestRemotePathService
());
instantiationService
.
stub
(
IConfigurationService
,
configService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
new
TestContextService
());
const
lifecycleService
=
new
TestLifecycleService
();
...
...
src/vs/workbench/services/label/common/labelService.ts
浏览文件 @
8d53e233
...
...
@@ -135,7 +135,7 @@ export class LabelService extends Disposable implements ILabelService {
private
doGetUriLabel
(
resource
:
URI
,
formatting
?:
ResourceLabelFormatting
,
options
:
{
relative
?:
boolean
,
noPrefix
?:
boolean
,
endWithSeparator
?:
boolean
}
=
{}):
string
{
if
(
!
formatting
)
{
return
getPathLabel
(
resource
.
path
,
this
.
environmentService
,
options
.
relative
?
this
.
contextService
:
undefined
);
return
getPathLabel
(
resource
.
path
,
{
userHome
:
this
.
remotePathService
.
resolvedUserHome
}
,
options
.
relative
?
this
.
contextService
:
undefined
);
}
let
label
:
string
|
undefined
;
...
...
@@ -266,7 +266,7 @@ export class LabelService extends Disposable implements ILabelService {
}
if
(
formatting
.
tildify
&&
!
forceNoTildify
)
{
const
userHome
=
this
.
remotePathService
.
userHomeSync
;
const
userHome
=
this
.
remotePathService
.
resolvedUserHome
;
if
(
userHome
)
{
label
=
tildify
(
label
,
userHome
.
fsPath
);
}
...
...
src/vs/workbench/services/label/test/browser/label.test.ts
浏览文件 @
8d53e233
...
...
@@ -5,10 +5,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
TestEnvironmentService
,
TestRemotePathService
}
from
'
vs/workbench/test/browser/workbenchTestServices
'
;
import
{
TestWorkspace
}
from
'
vs/platform/workspace/test/common/testWorkspace
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
sep
}
from
'
vs/base/common/path
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
LabelService
}
from
'
vs/workbench/services/label/common/labelService
'
;
import
{
TestContextService
}
from
'
vs/workbench/test/common/workbenchTestServices
'
;
...
...
@@ -17,28 +14,7 @@ suite('URI Label', () => {
let
labelService
:
LabelService
;
setup
(()
=>
{
labelService
=
new
LabelService
(
TestEnvironmentService
,
new
TestContextService
(),
new
TestRemotePathService
(
TestEnvironmentService
));
});
test
(
'
file scheme
'
,
function
()
{
labelService
.
registerFormatter
({
scheme
:
'
file
'
,
formatting
:
{
label
:
'
${path}
'
,
separator
:
sep
,
tildify
:
!
isWindows
,
normalizeDriveLetter
:
isWindows
}
});
const
uri1
=
TestWorkspace
.
folders
[
0
].
uri
.
with
({
path
:
TestWorkspace
.
folders
[
0
].
uri
.
path
.
concat
(
'
/a/b/c/d
'
)
});
assert
.
equal
(
labelService
.
getUriLabel
(
uri1
,
{
relative
:
true
}),
isWindows
?
'
a
\\
b
\\
c
\\
d
'
:
'
a/b/c/d
'
);
assert
.
equal
(
labelService
.
getUriLabel
(
uri1
,
{
relative
:
false
}),
isWindows
?
'
C:
\\
testWorkspace
\\
a
\\
b
\\
c
\\
d
'
:
'
/testWorkspace/a/b/c/d
'
);
assert
.
equal
(
labelService
.
getUriBasenameLabel
(
uri1
),
'
d
'
);
const
uri2
=
URI
.
file
(
'
c:
\\
1/2/3
'
);
assert
.
equal
(
labelService
.
getUriLabel
(
uri2
,
{
relative
:
false
}),
isWindows
?
'
C:
\\
1
\\
2
\\
3
'
:
'
/c:
\\
1/2/3
'
);
assert
.
equal
(
labelService
.
getUriBasenameLabel
(
uri2
),
'
3
'
);
labelService
=
new
LabelService
(
TestEnvironmentService
,
new
TestContextService
(),
new
TestRemotePathService
());
});
test
(
'
custom scheme
'
,
function
()
{
...
...
src/vs/workbench/services/label/test/electron-browser/label.test.ts
0 → 100644
浏览文件 @
8d53e233
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
TestWorkspace
}
from
'
vs/platform/workspace/test/common/testWorkspace
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
sep
}
from
'
vs/base/common/path
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
LabelService
}
from
'
vs/workbench/services/label/common/labelService
'
;
import
{
TestContextService
}
from
'
vs/workbench/test/common/workbenchTestServices
'
;
import
{
TestNativeRemotePathService
,
TestEnvironmentService
}
from
'
vs/workbench/test/electron-browser/workbenchTestServices
'
;
suite
(
'
URI Label
'
,
()
=>
{
let
labelService
:
LabelService
;
setup
(()
=>
{
labelService
=
new
LabelService
(
TestEnvironmentService
,
new
TestContextService
(),
new
TestNativeRemotePathService
(
TestEnvironmentService
));
});
test
(
'
file scheme
'
,
function
()
{
labelService
.
registerFormatter
({
scheme
:
'
file
'
,
formatting
:
{
label
:
'
${path}
'
,
separator
:
sep
,
tildify
:
!
isWindows
,
normalizeDriveLetter
:
isWindows
}
});
const
uri1
=
TestWorkspace
.
folders
[
0
].
uri
.
with
({
path
:
TestWorkspace
.
folders
[
0
].
uri
.
path
.
concat
(
'
/a/b/c/d
'
)
});
assert
.
equal
(
labelService
.
getUriLabel
(
uri1
,
{
relative
:
true
}),
isWindows
?
'
a
\\
b
\\
c
\\
d
'
:
'
a/b/c/d
'
);
assert
.
equal
(
labelService
.
getUriLabel
(
uri1
,
{
relative
:
false
}),
isWindows
?
'
C:
\\
testWorkspace
\\
a
\\
b
\\
c
\\
d
'
:
'
/testWorkspace/a/b/c/d
'
);
assert
.
equal
(
labelService
.
getUriBasenameLabel
(
uri1
),
'
d
'
);
const
uri2
=
URI
.
file
(
'
c:
\\
1/2/3
'
);
assert
.
equal
(
labelService
.
getUriLabel
(
uri2
,
{
relative
:
false
}),
isWindows
?
'
C:
\\
1
\\
2
\\
3
'
:
'
/c:
\\
1/2/3
'
);
assert
.
equal
(
labelService
.
getUriBasenameLabel
(
uri2
),
'
3
'
);
});
});
src/vs/workbench/services/path/browser/remotePathService.ts
0 → 100644
浏览文件 @
8d53e233
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IRemotePathService
,
AbstractRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
export
class
BrowserRemotePathService
extends
AbstractRemotePathService
{
private
static
fallbackUserHome
(
historyService
:
IHistoryService
,
environmentService
:
IWorkbenchEnvironmentService
):
URI
{
return
historyService
.
getLastActiveWorkspaceRoot
()
||
URI
.
from
({
scheme
:
Schemas
.
vscodeRemote
,
authority
:
environmentService
.
configuration
.
remoteAuthority
,
path
:
'
/
'
});
}
constructor
(
@
IRemoteAgentService
remoteAgentService
:
IRemoteAgentService
,
@
IHistoryService
historyService
:
IHistoryService
,
@
IWorkbenchEnvironmentService
environmentService
:
IWorkbenchEnvironmentService
)
{
super
(()
=>
BrowserRemotePathService
.
fallbackUserHome
(
historyService
,
environmentService
),
remoteAgentService
);
}
}
registerSingleton
(
IRemotePathService
,
BrowserRemotePathService
,
true
);
src/vs/workbench/services/path/common/remotePathService.ts
浏览文件 @
8d53e233
...
...
@@ -3,13 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
path
from
'
vs/base/common/path
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
IPath
,
win32
,
posix
}
from
'
vs/base/common/path
'
;
import
{
OperatingSystem
,
OS
}
from
'
vs/base/common/platform
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
const
REMOTE_PATH_SERVICE_ID
=
'
remotePath
'
;
export
const
IRemotePathService
=
createDecorator
<
IRemotePathService
>
(
REMOTE_PATH_SERVICE_ID
);
...
...
@@ -21,7 +19,7 @@ export interface IRemotePathService {
/**
* The path library to use for the target remote environment.
*/
readonly
path
:
Promise
<
path
.
IPath
>
;
readonly
path
:
Promise
<
IPath
>
;
/**
* Converts the given path to a file URI in the remote environment.
...
...
@@ -35,36 +33,50 @@ export interface IRemotePathService {
/**
* Provides access to the user home of the remote environment
* if defined.
* if defined. The variable will be `undefined` as long as the
* remote environment has not been resolved yet.
*/
readonly
userHomeSync
:
URI
|
undefined
;
readonly
resolvedUserHome
:
URI
|
undefined
;
}
/**
* Provides the correct IPath implementation for dealing with paths that refer to locations in the extension host
*/
export
class
RemotePathService
implements
IRemotePathService
{
export
abstract
class
AbstractRemotePathService
implements
IRemotePathService
{
_serviceBrand
:
undefined
;
private
_extHostOS
:
Promise
<
platform
.
OperatingSystem
>
;
private
_userHomeSync
:
URI
|
undefined
;
private
remoteOS
:
Promise
<
OperatingSystem
>
;
private
resolveUserHome
:
Promise
<
URI
>
;
private
maybeUnresolvedUserHome
:
URI
|
undefined
;
constructor
(
@
IRemoteAgentService
private
readonly
remoteAgentService
:
IRemoteAgentService
,
@
I
WorkbenchEnvironmentService
private
readonly
environmentService
:
IWorkbenchEnvironm
entService
fallbackUserHome
:
()
=>
URI
,
@
I
RemoteAgentService
private
readonly
remoteAgentService
:
IRemoteAg
entService
)
{
this
.
_extHostOS
=
remoteAgentService
.
getEnvironment
().
then
(
remoteEnvironment
=>
{
this
.
_userHomeSync
=
remoteEnvironment
?.
userHome
;
this
.
remoteOS
=
this
.
remoteAgentService
.
getEnvironment
().
then
(
env
=>
env
?.
os
||
OS
);
this
.
resolveUserHome
=
this
.
remoteAgentService
.
getEnvironment
().
then
(
env
=>
{
const
userHome
=
this
.
maybeUnresolvedUserHome
=
env
?.
userHome
||
fallbackUserHome
();
return
remoteEnvironment
?
remoteEnvironment
.
os
:
platform
.
OS
;
return
userHome
;
});
}
get
path
():
Promise
<
path
.
IPath
>
{
return
this
.
_extHostOS
.
then
(
os
=>
{
return
os
===
platform
.
OperatingSystem
.
Windows
?
path
.
win32
:
path
.
posix
;
get
userHome
():
Promise
<
URI
>
{
return
this
.
resolveUserHome
;
}
get
resolvedUserHome
():
URI
|
undefined
{
return
this
.
maybeUnresolvedUserHome
;
}
get
path
():
Promise
<
IPath
>
{
return
this
.
remoteOS
.
then
(
os
=>
{
return
os
===
OperatingSystem
.
Windows
?
win32
:
posix
;
});
}
...
...
@@ -74,7 +86,7 @@ export class RemotePathService implements IRemotePathService {
// normalize to fwd-slashes on windows,
// on other systems bwd-slashes are valid
// filename character, eg /f\oo/ba\r.txt
if
((
await
this
.
_extHostOS
)
===
platform
.
OperatingSystem
.
Windows
)
{
if
((
await
this
.
remoteOS
)
===
OperatingSystem
.
Windows
)
{
_path
=
_path
.
replace
(
/
\\
/g
,
'
/
'
);
}
...
...
@@ -100,23 +112,4 @@ export class RemotePathService implements IRemotePathService {
fragment
:
''
});
}
get
userHome
():
Promise
<
URI
>
{
return
this
.
remoteAgentService
.
getEnvironment
().
then
(
env
=>
{
// remote: use remote environment userHome
if
(
env
)
{
return
env
.
userHome
;
}
// local: use the userHome from environment
return
this
.
environmentService
.
userHome
!
;
});
}
get
userHomeSync
():
URI
|
undefined
{
return
this
.
_userHomeSync
||
this
.
environmentService
.
userHome
;
}
}
registerSingleton
(
IRemotePathService
,
RemotePathService
,
true
);
src/vs/workbench/services/path/electron-browser/remotePathService.ts
0 → 100644
浏览文件 @
8d53e233
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IRemotePathService
,
AbstractRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
import
{
INativeWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/electron-browser/environmentService
'
;
export
class
NativeRemotePathService
extends
AbstractRemotePathService
{
constructor
(
@
IRemoteAgentService
remoteAgentService
:
IRemoteAgentService
,
@
IWorkbenchEnvironmentService
environmentService
:
INativeWorkbenchEnvironmentService
)
{
super
(()
=>
environmentService
.
userHome
,
remoteAgentService
);
}
}
registerSingleton
(
IRemotePathService
,
NativeRemotePathService
,
true
);
src/vs/workbench/test/browser/workbenchTestServices.ts
浏览文件 @
8d53e233
...
...
@@ -115,7 +115,10 @@ export interface ITestInstantiationService extends IInstantiationService {
stub
<
T
>
(
service
:
ServiceIdentifier
<
T
>
,
ctor
:
any
):
T
;
}
export
function
workbenchInstantiationService
(
overrides
?:
{
textFileService
?:
(
instantiationService
:
IInstantiationService
)
=>
ITextFileService
}):
ITestInstantiationService
{
export
function
workbenchInstantiationService
(
overrides
?:
{
textFileService
?:
(
instantiationService
:
IInstantiationService
)
=>
ITextFileService
remotePathService
?:
(
instantiationService
:
IInstantiationService
)
=>
IRemotePathService
}):
ITestInstantiationService
{
const
instantiationService
=
new
TestInstantiationService
(
new
ServiceCollection
([
ILifecycleService
,
new
TestLifecycleService
()]));
instantiationService
.
stub
(
IWorkingCopyService
,
new
TestWorkingCopyService
());
...
...
@@ -131,7 +134,7 @@ export function workbenchInstantiationService(overrides?: { textFileService?: (i
instantiationService
.
stub
(
ITextResourceConfigurationService
,
new
TestTextResourceConfigurationService
(
configService
));
instantiationService
.
stub
(
IUntitledTextEditorService
,
instantiationService
.
createInstance
(
UntitledTextEditorService
));
instantiationService
.
stub
(
IStorageService
,
new
TestStorageService
());
instantiationService
.
stub
(
IRemotePathService
,
new
TestRemotePathService
(
TestEnvironmentService
));
instantiationService
.
stub
(
IRemotePathService
,
overrides
?.
remotePathService
?
overrides
.
remotePathService
(
instantiationService
)
:
new
TestRemotePathService
(
));
const
layoutService
=
new
TestLayoutService
();
instantiationService
.
stub
(
IWorkbenchLayoutService
,
layoutService
);
instantiationService
.
stub
(
IDialogService
,
new
TestDialogService
());
...
...
@@ -1108,12 +1111,12 @@ export class TestRemotePathService implements IRemotePathService {
_serviceBrand
:
undefined
;
constructor
(
@
IWorkbenchEnvironmentService
private
readonly
environmentService
:
IEnvironmentService
)
{
}
constructor
(
private
readonly
fallbackUserHome
:
URI
=
URI
.
from
({
scheme
:
Schemas
.
vscodeRemote
,
path
:
'
/
'
})
)
{
}
get
path
()
{
return
Promise
.
resolve
(
isWindows
?
win32
:
posix
);
}
get
userHome
()
{
return
Promise
.
resolve
(
this
.
environmentService
.
userHome
!
);
}
get
userHomeSync
()
{
return
this
.
environmentService
.
u
serHome
;
}
get
userHome
()
{
return
Promise
.
resolve
(
this
.
fallbackUserHome
);
}
get
resolvedUserHome
()
{
return
this
.
fallbackU
serHome
;
}
async
fileURI
(
path
:
string
):
Promise
<
URI
>
{
return
URI
.
file
(
path
);
...
...
src/vs/workbench/test/electron-browser/workbenchTestServices.ts
浏览文件 @
8d53e233
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
workbenchInstantiationService
as
browserWorkbenchInstantiationService
,
ITestInstantiationService
,
TestLifecycleService
,
TestFilesConfigurationService
,
TestFileService
,
TestFileDialogService
}
from
'
vs/workbench/test/browser/workbenchTestServices
'
;
import
{
workbenchInstantiationService
as
browserWorkbenchInstantiationService
,
ITestInstantiationService
,
TestLifecycleService
,
TestFilesConfigurationService
,
TestFileService
,
TestFileDialogService
,
TestRemotePathService
}
from
'
vs/workbench/test/browser/workbenchTestServices
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
ISharedProcessService
}
from
'
vs/platform/ipc/electron-browser/sharedProcessService
'
;
import
{
NativeWorkbenchEnvironmentService
,
INativeWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/electron-browser/environmentService
'
;
...
...
@@ -219,7 +219,8 @@ export class TestElectronService implements IElectronService {
export
function
workbenchInstantiationService
():
ITestInstantiationService
{
const
instantiationService
=
browserWorkbenchInstantiationService
({
textFileService
:
insta
=>
<
ITextFileService
>
insta
.
createInstance
(
TestTextFileService
)
textFileService
:
insta
=>
<
ITextFileService
>
insta
.
createInstance
(
TestTextFileService
),
remotePathService
:
insta
=>
<
IRemotePathService
>
insta
.
createInstance
(
TestNativeRemotePathService
)
});
instantiationService
.
stub
(
IElectronService
,
new
TestElectronService
());
...
...
@@ -243,3 +244,12 @@ export class TestServiceAccessor {
)
{
}
}
export
class
TestNativeRemotePathService
extends
TestRemotePathService
{
_serviceBrand
:
undefined
;
constructor
(@
IWorkbenchEnvironmentService
environmentService
:
INativeWorkbenchEnvironmentService
)
{
super
(
environmentService
.
userHome
);
}
}
src/vs/workbench/workbench.common.main.ts
浏览文件 @
8d53e233
...
...
@@ -76,7 +76,6 @@ import 'vs/workbench/services/extensionManagement/common/extensionEnablementServ
import
'
vs/workbench/services/notification/common/notificationService
'
;
import
'
vs/workbench/services/extensions/common/staticExtensions
'
;
import
'
vs/workbench/services/userDataSync/common/userDataSyncUtil
'
;
import
'
vs/workbench/services/path/common/remotePathService
'
;
import
'
vs/workbench/services/remote/common/remoteExplorerService
'
;
import
'
vs/workbench/services/workingCopy/common/workingCopyService
'
;
import
'
vs/workbench/services/workingCopy/common/workingCopyFileService
'
;
...
...
src/vs/workbench/workbench.desktop.main.ts
浏览文件 @
8d53e233
...
...
@@ -66,6 +66,7 @@ import 'vs/workbench/services/update/electron-browser/updateService';
import
'
vs/workbench/services/issue/electron-browser/issueService
'
;
import
'
vs/workbench/services/menubar/electron-browser/menubarService
'
;
import
'
vs/workbench/services/extensionResourceLoader/electron-browser/extensionResourceLoaderService
'
;
import
'
vs/workbench/services/path/electron-browser/remotePathService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
ICredentialsService
}
from
'
vs/platform/credentials/common/credentials
'
;
...
...
src/vs/workbench/workbench.web.main.ts
浏览文件 @
8d53e233
...
...
@@ -50,6 +50,7 @@ import 'vs/workbench/services/request/browser/requestService';
import
'
vs/workbench/services/lifecycle/browser/lifecycleService
'
;
import
'
vs/workbench/services/clipboard/browser/clipboardService
'
;
import
'
vs/workbench/services/extensionResourceLoader/browser/extensionResourceLoaderService
'
;
import
'
vs/workbench/services/path/browser/remotePathService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IAccessibilityService
}
from
'
vs/platform/accessibility/common/accessibility
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录