Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
752c7b78
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,发现更多精彩内容 >>
提交
752c7b78
编写于
1月 22, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first cut updateFolders API
上级
4bcaeaed
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
81 addition
and
5 deletion
+81
-5
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+13
-4
src/vs/workbench/services/configuration/test/node/configurationService.test.ts
...ices/configuration/test/node/configurationService.test.ts
+28
-0
src/vs/workbench/services/workspace/common/workspaceEditing.ts
...s/workbench/services/workspace/common/workspaceEditing.ts
+6
-0
src/vs/workbench/services/workspace/node/workspaceEditingService.ts
...kbench/services/workspace/node/workspaceEditingService.ts
+34
-1
未找到文件。
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
752c7b78
...
...
@@ -110,9 +110,9 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
return
this
.
workspace
.
getFolder
(
resource
);
}
public
addFolders
(
foldersToAdd
:
IWorkspaceFolderCreationData
[]):
TPromise
<
void
>
{
public
addFolders
(
foldersToAdd
:
IWorkspaceFolderCreationData
[]
,
index
?:
number
):
TPromise
<
void
>
{
assert
.
ok
(
this
.
jsonEditingService
,
'
Workbench is not initialized yet
'
);
return
this
.
workspaceEditingQueue
.
queue
(()
=>
this
.
doAddFolders
(
foldersToAdd
));
return
this
.
workspaceEditingQueue
.
queue
(()
=>
this
.
doAddFolders
(
foldersToAdd
,
index
));
}
public
removeFolders
(
foldersToRemove
:
URI
[]):
TPromise
<
void
>
{
...
...
@@ -134,7 +134,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
return
false
;
}
private
doAddFolders
(
foldersToAdd
:
IWorkspaceFolderCreationData
[]):
TPromise
<
void
>
{
private
doAddFolders
(
foldersToAdd
:
IWorkspaceFolderCreationData
[]
,
index
?:
number
):
TPromise
<
void
>
{
if
(
this
.
getWorkbenchState
()
!==
WorkbenchState
.
WORKSPACE
)
{
return
TPromise
.
as
(
void
0
);
// we need a workspace to begin with
}
...
...
@@ -176,7 +176,16 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
});
if
(
storedFoldersToAdd
.
length
>
0
)
{
return
this
.
setFolders
([...
currentStoredFolders
,
...
storedFoldersToAdd
]);
let
newStoredWorkspaceFolders
:
IStoredWorkspaceFolder
[]
=
[];
if
(
typeof
index
===
'
number
'
&&
index
>=
0
&&
index
<
currentStoredFolders
.
length
-
1
)
{
newStoredWorkspaceFolders
=
currentStoredFolders
.
slice
(
0
);
newStoredWorkspaceFolders
.
splice
(
index
,
0
,
...
storedFoldersToAdd
);
}
else
{
newStoredWorkspaceFolders
=
[...
currentStoredFolders
,
...
storedFoldersToAdd
];
}
return
this
.
setFolders
(
newStoredWorkspaceFolders
);
}
return
TPromise
.
as
(
void
0
);
...
...
src/vs/workbench/services/configuration/test/node/configurationService.test.ts
浏览文件 @
752c7b78
...
...
@@ -192,6 +192,34 @@ suite('WorkspaceContextService - Workspace', () => {
});
});
test
(
'
add folders (at specific index)
'
,
()
=>
{
const
workspaceDir
=
path
.
dirname
(
testObject
.
getWorkspace
().
folders
[
0
].
uri
.
fsPath
);
return
testObject
.
addFolders
([{
uri
:
URI
.
file
(
path
.
join
(
workspaceDir
,
'
d
'
))
},
{
uri
:
URI
.
file
(
path
.
join
(
workspaceDir
,
'
c
'
))
}],
0
)
.
then
(()
=>
{
const
actual
=
testObject
.
getWorkspace
().
folders
;
assert
.
equal
(
actual
.
length
,
4
);
assert
.
equal
(
path
.
basename
(
actual
[
0
].
uri
.
fsPath
),
'
d
'
);
assert
.
equal
(
path
.
basename
(
actual
[
1
].
uri
.
fsPath
),
'
c
'
);
assert
.
equal
(
path
.
basename
(
actual
[
2
].
uri
.
fsPath
),
'
a
'
);
assert
.
equal
(
path
.
basename
(
actual
[
3
].
uri
.
fsPath
),
'
b
'
);
});
});
test
(
'
add folders (at specific wrong index)
'
,
()
=>
{
const
workspaceDir
=
path
.
dirname
(
testObject
.
getWorkspace
().
folders
[
0
].
uri
.
fsPath
);
return
testObject
.
addFolders
([{
uri
:
URI
.
file
(
path
.
join
(
workspaceDir
,
'
d
'
))
},
{
uri
:
URI
.
file
(
path
.
join
(
workspaceDir
,
'
c
'
))
}],
10
)
.
then
(()
=>
{
const
actual
=
testObject
.
getWorkspace
().
folders
;
assert
.
equal
(
actual
.
length
,
4
);
assert
.
equal
(
path
.
basename
(
actual
[
0
].
uri
.
fsPath
),
'
a
'
);
assert
.
equal
(
path
.
basename
(
actual
[
1
].
uri
.
fsPath
),
'
b
'
);
assert
.
equal
(
path
.
basename
(
actual
[
2
].
uri
.
fsPath
),
'
d
'
);
assert
.
equal
(
path
.
basename
(
actual
[
3
].
uri
.
fsPath
),
'
c
'
);
});
});
test
(
'
add folders (with name)
'
,
()
=>
{
const
workspaceDir
=
path
.
dirname
(
testObject
.
getWorkspace
().
folders
[
0
].
uri
.
fsPath
);
return
testObject
.
addFolders
([{
uri
:
URI
.
file
(
path
.
join
(
workspaceDir
,
'
d
'
)),
name
:
'
DDD
'
},
{
uri
:
URI
.
file
(
path
.
join
(
workspaceDir
,
'
c
'
)),
name
:
'
CCC
'
}])
...
...
src/vs/workbench/services/workspace/common/workspaceEditing.ts
浏览文件 @
752c7b78
...
...
@@ -27,6 +27,12 @@ export interface IWorkspaceEditingService {
*/
removeFolders
(
folders
:
URI
[],
donotNotifyError
?:
boolean
):
TPromise
<
void
>
;
/**
* Allows to add and remove folders to the existing workspace at once.
* When `donotNotifyError` is `true`, error will be bubbled up otherwise, the service handles the error with proper message and action
*/
updateFolders
(
index
:
number
,
deleteCount
?:
number
,
foldersToAdd
?:
IWorkspaceFolderCreationData
[],
donotNotifyError
?:
boolean
):
TPromise
<
void
>
;
/**
* creates a new workspace with the provided folders and opens it. if path is provided
* the workspace will be saved into that location.
...
...
src/vs/workbench/services/workspace/node/workspaceEditingService.ts
浏览文件 @
752c7b78
...
...
@@ -47,7 +47,40 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
)
{
}
public
updateFolders
(
index
:
number
,
deleteCount
?:
number
,
foldersToAdd
?:
IWorkspaceFolderCreationData
[],
donotNotifyError
?:
boolean
):
TPromise
<
void
>
{
const
folders
=
this
.
contextService
.
getWorkspace
().
folders
;
if
(
index
<
0
||
index
>
folders
.
length
-
1
)
{
return
TPromise
.
wrapError
(
new
Error
(
nls
.
localize
(
'
errorInvalidIndex
'
,
"
The index for updating workspace folders is invalid.
"
)));
}
if
(
typeof
deleteCount
===
'
number
'
&&
(
deleteCount
<
0
||
index
+
deleteCount
>
folders
.
length
-
1
))
{
return
TPromise
.
wrapError
(
new
Error
(
nls
.
localize
(
'
errorInvalidDelete
'
,
"
The number of workspace folders to delete is invalid.
"
)));
}
const
wantsToDelete
=
typeof
deleteCount
===
'
number
'
;
const
wantsToAdd
=
Array
.
isArray
(
foldersToAdd
)
&&
foldersToAdd
.
length
;
// Add Folders
if
(
wantsToAdd
&&
!
wantsToDelete
)
{
return
this
.
doAddFolders
(
foldersToAdd
,
index
,
donotNotifyError
);
}
// Delete Folders
if
(
wantsToDelete
&&
!
wantsToAdd
)
{
return
this
.
removeFolders
(
folders
.
slice
(
index
,
index
+
deleteCount
).
map
(
f
=>
f
.
uri
));
}
// Add & Delete Folders (first remove and then add to allow for updating existing folders)
return
this
.
removeFolders
(
folders
.
slice
(
index
,
index
+
deleteCount
).
map
(
f
=>
f
.
uri
)).
then
(()
=>
{
return
this
.
doAddFolders
(
foldersToAdd
,
index
,
donotNotifyError
);
});
}
public
addFolders
(
foldersToAdd
:
IWorkspaceFolderCreationData
[],
donotNotifyError
:
boolean
=
false
):
TPromise
<
void
>
{
return
this
.
doAddFolders
(
foldersToAdd
,
void
0
,
donotNotifyError
);
}
private
doAddFolders
(
foldersToAdd
:
IWorkspaceFolderCreationData
[],
index
?:
number
,
donotNotifyError
:
boolean
=
false
):
TPromise
<
void
>
{
const
state
=
this
.
contextService
.
getWorkbenchState
();
// If we are in no-workspace or single-folder workspace, adding folders has to
...
...
@@ -66,7 +99,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
}
// Delegate addition of folders to workspace service otherwise
return
this
.
contextService
.
addFolders
(
foldersToAdd
)
return
this
.
contextService
.
addFolders
(
foldersToAdd
,
index
)
.
then
(()
=>
null
,
error
=>
donotNotifyError
?
TPromise
.
wrapError
(
error
)
:
this
.
handleWorkspaceConfigurationEditingError
(
error
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录