Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
044c8ed8
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,发现更多精彩内容 >>
提交
044c8ed8
编写于
4月 16, 2019
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
toWorkspaceFolders takes workspaceConfigPath
上级
e5f694eb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
28 addition
and
26 deletion
+28
-26
src/vs/code/test/node/windowsFinder.test.ts
src/vs/code/test/node/windowsFinder.test.ts
+1
-2
src/vs/editor/contrib/snippet/test/snippetVariables.test.ts
src/vs/editor/contrib/snippet/test/snippetVariables.test.ts
+2
-3
src/vs/platform/workspace/common/workspace.ts
src/vs/platform/workspace/common/workspace.ts
+2
-1
src/vs/platform/workspace/test/common/workspace.test.ts
src/vs/platform/workspace/test/common/workspace.test.ts
+11
-9
src/vs/platform/workspaces/electron-main/workspacesMainService.ts
...latform/workspaces/electron-main/workspacesMainService.ts
+2
-2
src/vs/workbench/contrib/search/test/common/queryBuilder.test.ts
...workbench/contrib/search/test/common/queryBuilder.test.ts
+5
-5
src/vs/workbench/services/configuration/browser/configurationService.ts
...ch/services/configuration/browser/configurationService.ts
+5
-4
未找到文件。
src/vs/code/test/node/windowsFinder.test.ts
浏览文件 @
044c8ed8
...
...
@@ -10,7 +10,6 @@ import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import
{
toWorkspaceFolders
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
getPathFromAmdModule
}
from
'
vs/base/common/amd
'
;
import
{
dirname
}
from
'
vs/base/common/resources
'
;
const
fixturesFolder
=
getPathFromAmdModule
(
require
,
'
./fixtures
'
);
...
...
@@ -19,7 +18,7 @@ const testWorkspace: IWorkspaceIdentifier = {
configPath
:
URI
.
file
(
path
.
join
(
fixturesFolder
,
'
workspaces.json
'
))
};
const
testWorkspaceFolders
=
toWorkspaceFolders
([{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_1_folder
'
)
},
{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_2_folder
'
)
}],
dirname
(
testWorkspace
.
configPath
)
);
const
testWorkspaceFolders
=
toWorkspaceFolders
([{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_1_folder
'
)
},
{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_2_folder
'
)
}],
testWorkspace
.
configPath
);
function
options
(
custom
?:
Partial
<
IBestWindowOrFolderOptions
<
ISimpleWindow
>>
):
IBestWindowOrFolderOptions
<
ISimpleWindow
>
{
return
{
...
...
src/vs/editor/contrib/snippet/test/snippetVariables.test.ts
浏览文件 @
044c8ed8
...
...
@@ -332,9 +332,8 @@ suite('Snippet Variables Resolver', function () {
assertVariableResolve
(
resolver
,
'
WORKSPACE_NAME
'
,
'
folderName
'
);
// workspace with config
const
workspaceFile
=
URI
.
file
(
'
testWorkspace.code-workspace
'
);
const
workspaceDir
=
URI
.
file
(
'
workspace
'
);
workspace
=
new
Workspace
(
''
,
toWorkspaceFolders
([{
path
:
'
folderName
'
}],
workspaceDir
),
workspaceFile
);
const
workspaceConfigPath
=
URI
.
file
(
'
testWorkspace.code-workspace
'
);
workspace
=
new
Workspace
(
''
,
toWorkspaceFolders
([{
path
:
'
folderName
'
}],
workspaceConfigPath
),
workspaceConfigPath
);
assertVariableResolve
(
resolver
,
'
WORKSPACE_NAME
'
,
'
testWorkspace
'
);
});
});
\ No newline at end of file
src/vs/platform/workspace/common/workspace.ts
浏览文件 @
044c8ed8
...
...
@@ -226,10 +226,11 @@ export function toWorkspaceFolder(resource: URI): WorkspaceFolder {
return
new
WorkspaceFolder
({
uri
:
resource
,
index
:
0
,
name
:
resources
.
basenameOrAuthority
(
resource
)
},
{
uri
:
resource
.
toString
()
});
}
export
function
toWorkspaceFolders
(
configuredFolders
:
IStoredWorkspaceFolder
[],
relativeTo
:
URI
):
WorkspaceFolder
[]
{
export
function
toWorkspaceFolders
(
configuredFolders
:
IStoredWorkspaceFolder
[],
workspaceConfigFile
:
URI
):
WorkspaceFolder
[]
{
let
result
:
WorkspaceFolder
[]
=
[];
let
seen
:
{
[
uri
:
string
]:
boolean
}
=
Object
.
create
(
null
);
const
relativeTo
=
resources
.
dirname
(
workspaceConfigFile
);
for
(
let
configuredFolder
of
configuredFolders
)
{
let
uri
:
URI
|
null
=
null
;
if
(
isRawFileWorkspaceFolder
(
configuredFolder
))
{
...
...
src/vs/platform/workspace/test/common/workspace.test.ts
浏览文件 @
044c8ed8
...
...
@@ -10,6 +10,8 @@ import { IRawFileWorkspaceFolder } from 'vs/platform/workspaces/common/workspace
suite
(
'
Workspace
'
,
()
=>
{
const
workspaceConfigPath
=
URI
.
file
(
'
/src/test.code-workspace
'
);
test
(
'
getFolder returns the folder with given uri
'
,
()
=>
{
const
expected
=
new
WorkspaceFolder
({
uri
:
URI
.
file
(
'
/src/test
'
),
name
:
''
,
index
:
2
});
let
testObject
=
new
Workspace
(
''
,
[
new
WorkspaceFolder
({
uri
:
URI
.
file
(
'
/src/main
'
),
name
:
''
,
index
:
0
}),
expected
,
new
WorkspaceFolder
({
uri
:
URI
.
file
(
'
/src/code
'
),
name
:
''
,
index
:
2
})]);
...
...
@@ -46,7 +48,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with single absolute folder
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test
'
}],
URI
.
file
(
'
/workspaces
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
1
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test
'
).
fsPath
);
...
...
@@ -56,7 +58,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with single relative folder
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
./test
'
}],
URI
.
file
(
'
src
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
./test
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
1
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test
'
).
fsPath
);
...
...
@@ -66,7 +68,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with single absolute folder with name
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test
'
,
name
:
'
hello
'
}],
URI
.
file
(
'
/workspaces
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test
'
,
name
:
'
hello
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
1
);
...
...
@@ -77,7 +79,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with multiple unique absolute folders
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test3
'
},
{
path
:
'
/src/test1
'
}],
URI
.
file
(
'
/workspaces
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test3
'
},
{
path
:
'
/src/test1
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
3
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test2
'
).
fsPath
);
...
...
@@ -97,7 +99,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with multiple unique absolute folders with names
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test3
'
,
name
:
'
noName
'
},
{
path
:
'
/src/test1
'
}],
URI
.
file
(
'
/workspaces
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test3
'
,
name
:
'
noName
'
},
{
path
:
'
/src/test1
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
3
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test2
'
).
fsPath
);
...
...
@@ -117,7 +119,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with multiple unique absolute and relative folders
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/abc/test3
'
,
name
:
'
noName
'
},
{
path
:
'
./test1
'
}],
URI
.
file
(
'
src
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/abc/test3
'
,
name
:
'
noName
'
},
{
path
:
'
./test1
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
3
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test2
'
).
fsPath
);
...
...
@@ -137,7 +139,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with multiple absolute folders with duplicates
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test2
'
,
name
:
'
noName
'
},
{
path
:
'
/src/test1
'
}],
URI
.
file
(
'
/workspaces
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test2
'
,
name
:
'
noName
'
},
{
path
:
'
/src/test1
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
2
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test2
'
).
fsPath
);
...
...
@@ -152,7 +154,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with multiple absolute and relative folders with duplicates
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test3
'
,
name
:
'
noName
'
},
{
path
:
'
./test3
'
},
{
path
:
'
/abc/test1
'
}],
URI
.
file
(
'
src
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
'
/src/test3
'
,
name
:
'
noName
'
},
{
path
:
'
./test3
'
},
{
path
:
'
/abc/test1
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
3
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test2
'
).
fsPath
);
...
...
@@ -172,7 +174,7 @@ suite('Workspace', () => {
});
test
(
'
toWorkspaceFolders with multiple absolute and relative folders with invalid paths
'
,
()
=>
{
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
''
,
name
:
'
noName
'
},
{
path
:
'
./test3
'
},
{
path
:
'
/abc/test1
'
}],
URI
.
file
(
'
src
'
)
);
const
actual
=
toWorkspaceFolders
([{
path
:
'
/src/test2
'
},
{
path
:
''
,
name
:
'
noName
'
},
{
path
:
'
./test3
'
},
{
path
:
'
/abc/test1
'
}],
workspaceConfigPath
);
assert
.
equal
(
actual
.
length
,
3
);
assert
.
equal
(
actual
[
0
].
uri
.
fsPath
,
URI
.
file
(
'
/src/test2
'
).
fsPath
);
...
...
src/vs/platform/workspaces/electron-main/workspacesMainService.ts
浏览文件 @
044c8ed8
...
...
@@ -17,7 +17,7 @@ import { toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
originalFSPath
,
dirname
as
resourcesDirname
,
isEqualOrParent
,
joinPath
}
from
'
vs/base/common/resources
'
;
import
{
originalFSPath
,
isEqualOrParent
,
joinPath
}
from
'
vs/base/common/resources
'
;
export
interface
IStoredWorkspace
{
folders
:
IStoredWorkspaceFolder
[];
...
...
@@ -71,7 +71,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
return
{
id
:
workspaceIdentifier
.
id
,
configPath
:
workspaceIdentifier
.
configPath
,
folders
:
toWorkspaceFolders
(
workspace
.
folders
,
resourcesDirname
(
path
)
),
folders
:
toWorkspaceFolders
(
workspace
.
folders
,
workspaceIdentifier
.
configPath
),
remoteAuthority
:
workspace
.
remoteAuthority
};
}
catch
(
error
)
{
...
...
src/vs/workbench/contrib/search/test/common/queryBuilder.test.ts
浏览文件 @
044c8ed8
...
...
@@ -24,7 +24,7 @@ suite('QueryBuilder', () => {
const
PATTERN_INFO
:
IPatternInfo
=
{
pattern
:
'
a
'
};
const
ROOT_1
=
fixPath
(
'
/foo/root1
'
);
const
ROOT_1_URI
=
getUri
(
ROOT_1
);
const
WS_
FOLDER
=
getUri
(
'
/bar
'
);
// location of the workspace file (not important except that it is a file URI)
const
WS_
CONFIG_PATH
=
getUri
(
'
/bar/test.code-workspace
'
);
// location of the workspace file (not important except that it is a file URI)
let
instantiationService
:
TestInstantiationService
;
let
queryBuilder
:
QueryBuilder
;
...
...
@@ -278,7 +278,7 @@ suite('QueryBuilder', () => {
const
ROOT_2_URI
=
getUri
(
ROOT_2
);
const
ROOT_3
=
fixPath
(
'
/project/root3
'
);
const
ROOT_3_URI
=
getUri
(
ROOT_3
);
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
},
{
path
:
ROOT_2_URI
.
fsPath
},
{
path
:
ROOT_3_URI
.
fsPath
}],
WS_
FOLDER
);
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
},
{
path
:
ROOT_2_URI
.
fsPath
},
{
path
:
ROOT_3_URI
.
fsPath
}],
WS_
CONFIG_PATH
);
mockWorkspace
.
configuration
=
uri
.
file
(
fixPath
(
'
/config
'
));
mockConfigService
.
setUserConfiguration
(
'
search
'
,
{
...
...
@@ -690,7 +690,7 @@ suite('QueryBuilder', () => {
test
(
'
relative includes w/two root folders
'
,
()
=>
{
const
ROOT_2
=
'
/project/root2
'
;
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
},
{
path
:
getUri
(
ROOT_2
).
fsPath
}],
WS_
FOLDER
);
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
},
{
path
:
getUri
(
ROOT_2
).
fsPath
}],
WS_
CONFIG_PATH
);
mockWorkspace
.
configuration
=
uri
.
file
(
fixPath
(
'
config
'
));
const
cases
:
[
string
,
ISearchPathsInfo
][]
=
[
...
...
@@ -731,7 +731,7 @@ suite('QueryBuilder', () => {
test
(
'
include ./foldername
'
,
()
=>
{
const
ROOT_2
=
'
/project/root2
'
;
const
ROOT_1_FOLDERNAME
=
'
foldername
'
;
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
,
name
:
ROOT_1_FOLDERNAME
},
{
path
:
getUri
(
ROOT_2
).
fsPath
}],
WS_
FOLDER
);
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
,
name
:
ROOT_1_FOLDERNAME
},
{
path
:
getUri
(
ROOT_2
).
fsPath
}],
WS_
CONFIG_PATH
);
mockWorkspace
.
configuration
=
uri
.
file
(
fixPath
(
'
config
'
));
const
cases
:
[
string
,
ISearchPathsInfo
][]
=
[
...
...
@@ -759,7 +759,7 @@ suite('QueryBuilder', () => {
test
(
'
relative includes w/multiple ambiguous root folders
'
,
()
=>
{
const
ROOT_2
=
'
/project/rootB
'
;
const
ROOT_3
=
'
/otherproject/rootB
'
;
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
},
{
path
:
getUri
(
ROOT_2
).
fsPath
},
{
path
:
getUri
(
ROOT_3
).
fsPath
}],
WS_
FOLDER
);
mockWorkspace
.
folders
=
toWorkspaceFolders
([{
path
:
ROOT_1_URI
.
fsPath
},
{
path
:
getUri
(
ROOT_2
).
fsPath
},
{
path
:
getUri
(
ROOT_3
).
fsPath
}],
WS_
CONFIG_PATH
);
mockWorkspace
.
configuration
=
uri
.
file
(
fixPath
(
'
/config
'
));
const
cases
:
[
string
,
ISearchPathsInfo
][]
=
[
...
...
src/vs/workbench/services/configuration/browser/configurationService.ts
浏览文件 @
044c8ed8
...
...
@@ -181,8 +181,9 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
if
(
foldersToAdd
.
length
)
{
// Recompute current workspace folders if we have folders to add
const
workspaceConfigFolder
=
dirname
(
this
.
getWorkspace
().
configuration
!
);
currentWorkspaceFolders
=
toWorkspaceFolders
(
newStoredFolders
,
workspaceConfigFolder
);
const
workspaceConfigPath
=
this
.
getWorkspace
().
configuration
!
;
const
workspaceConfigFolder
=
dirname
(
workspaceConfigPath
);
currentWorkspaceFolders
=
toWorkspaceFolders
(
newStoredFolders
,
workspaceConfigPath
);
const
currentWorkspaceFolderUris
=
currentWorkspaceFolders
.
map
(
folder
=>
folder
.
uri
);
const
storedFoldersToAdd
:
IStoredWorkspaceFolder
[]
=
[];
...
...
@@ -329,7 +330,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
return
this
.
workspaceConfiguration
.
load
({
id
:
workspaceIdentifier
.
id
,
configPath
:
workspaceIdentifier
.
configPath
})
.
then
(()
=>
{
const
workspaceConfigPath
=
workspaceIdentifier
.
configPath
;
const
workspaceFolders
=
toWorkspaceFolders
(
this
.
workspaceConfiguration
.
getFolders
(),
dirname
(
workspaceConfigPath
)
);
const
workspaceFolders
=
toWorkspaceFolders
(
this
.
workspaceConfiguration
.
getFolders
(),
workspaceConfigPath
);
const
workspaceId
=
workspaceIdentifier
.
id
;
const
workspace
=
new
Workspace
(
workspaceId
,
workspaceFolders
,
workspaceConfigPath
);
if
(
this
.
workspaceConfiguration
.
loaded
)
{
...
...
@@ -549,7 +550,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
private
onWorkspaceConfigurationChanged
():
Promise
<
void
>
{
if
(
this
.
workspace
&&
this
.
workspace
.
configuration
&&
this
.
_configuration
)
{
const
workspaceConfigurationChangeEvent
=
this
.
_configuration
.
compareAndUpdateWorkspaceConfiguration
(
this
.
workspaceConfiguration
.
getConfiguration
());
let
configuredFolders
=
toWorkspaceFolders
(
this
.
workspaceConfiguration
.
getFolders
(),
dirname
(
this
.
workspace
.
configuration
)
);
let
configuredFolders
=
toWorkspaceFolders
(
this
.
workspaceConfiguration
.
getFolders
(),
this
.
workspace
.
configuration
);
const
changes
=
this
.
compareFolders
(
this
.
workspace
.
folders
,
configuredFolders
);
if
(
changes
.
added
.
length
||
changes
.
removed
.
length
||
changes
.
changed
.
length
)
{
this
.
workspace
.
folders
=
configuredFolders
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录