Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d77d7d29
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 搜索 >>
提交
d77d7d29
编写于
2月 11, 2019
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
workspaceHome -> untitledWorkspacesHome, is URI
上级
b34154e0
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
67 addition
and
70 deletion
+67
-70
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+3
-3
src/vs/code/node/windowsFinder.ts
src/vs/code/node/windowsFinder.ts
+5
-5
src/vs/code/test/node/windowsFinder.test.ts
src/vs/code/test/node/windowsFinder.test.ts
+1
-1
src/vs/platform/environment/common/environment.ts
src/vs/platform/environment/common/environment.ts
+1
-1
src/vs/platform/environment/node/environmentService.ts
src/vs/platform/environment/node/environmentService.ts
+1
-1
src/vs/platform/history/electron-main/historyMainService.ts
src/vs/platform/history/electron-main/historyMainService.ts
+1
-1
src/vs/platform/label/common/label.ts
src/vs/platform/label/common/label.ts
+2
-2
src/vs/platform/launch/electron-main/launchService.ts
src/vs/platform/launch/electron-main/launchService.ts
+1
-2
src/vs/platform/workspaces/common/workspaces.ts
src/vs/platform/workspaces/common/workspaces.ts
+1
-1
src/vs/platform/workspaces/electron-main/workspacesMainService.ts
...latform/workspaces/electron-main/workspacesMainService.ts
+32
-33
src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts
...rkspaces/test/electron-main/workspacesMainService.test.ts
+14
-14
src/vs/workbench/services/dialogs/electron-browser/dialogService.ts
...kbench/services/dialogs/electron-browser/dialogService.ts
+4
-5
src/vs/workbench/services/label/common/labelService.ts
src/vs/workbench/services/label/common/labelService.ts
+1
-1
未找到文件。
src/vs/code/electron-main/windows.ts
浏览文件 @
d77d7d29
...
...
@@ -531,7 +531,7 @@ export class WindowsManager implements IWindowsMainService {
newWindow
:
openFilesInNewWindow
,
context
:
openConfig
.
context
,
fileUri
:
fileToCheck
&&
fileToCheck
.
fileUri
,
workspaceResolver
:
workspace
=>
workspace
.
configPath
.
scheme
===
Schemas
.
file
?
this
.
workspacesMainService
.
resolveWorkspaceSync
(
fsPath
(
workspace
.
configPath
)
)
:
null
localWorkspaceResolver
:
workspace
=>
workspace
.
configPath
.
scheme
===
Schemas
.
file
?
this
.
workspacesMainService
.
resolveLocalWorkspaceSync
(
workspace
.
configPath
)
:
null
});
// We found a window to open the files in
...
...
@@ -1051,7 +1051,7 @@ export class WindowsManager implements IWindowsMainService {
// Workspace (unless disabled via flag)
if
(
!
options
.
forceOpenWorkspaceAsFile
)
{
const
workspace
=
this
.
workspacesMainService
.
resolve
WorkspaceSync
(
candidate
);
const
workspace
=
this
.
workspacesMainService
.
resolve
LocalWorkspaceSync
(
URI
.
file
(
candidate
)
);
if
(
workspace
)
{
return
{
workspace
:
{
id
:
workspace
.
id
,
configPath
:
workspace
.
configPath
},
remoteAuthority
};
}
...
...
@@ -2128,7 +2128,7 @@ class WorkspacesManager {
return
workspace
.
scheme
===
Schemas
.
file
?
dirname
(
workspace
.
fsPath
)
:
undefined
;
}
const
resolvedWorkspace
=
workspace
.
configPath
.
scheme
===
Schemas
.
file
&&
this
.
workspacesMainService
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
);
const
resolvedWorkspace
=
workspace
.
configPath
.
scheme
===
Schemas
.
file
&&
this
.
workspacesMainService
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
);
if
(
resolvedWorkspace
&&
resolvedWorkspace
.
folders
.
length
>
0
)
{
for
(
const
folder
of
resolvedWorkspace
.
folders
)
{
if
(
folder
.
uri
.
scheme
===
Schemas
.
file
)
{
...
...
src/vs/code/node/windowsFinder.ts
浏览文件 @
d77d7d29
...
...
@@ -25,10 +25,10 @@ export interface IBestWindowOrFolderOptions<W extends ISimpleWindow> {
fileUri
?:
URI
;
userHome
?:
string
;
codeSettingsFolder
?:
string
;
w
orkspaceResolver
:
(
workspace
:
IWorkspaceIdentifier
)
=>
IResolvedWorkspace
|
null
;
localW
orkspaceResolver
:
(
workspace
:
IWorkspaceIdentifier
)
=>
IResolvedWorkspace
|
null
;
}
export
function
findBestWindowOrFolderForFile
<
W
extends
ISimpleWindow
>
({
windows
,
newWindow
,
context
,
fileUri
,
workspaceResolver
}:
IBestWindowOrFolderOptions
<
W
>
):
W
|
undefined
{
export
function
findBestWindowOrFolderForFile
<
W
extends
ISimpleWindow
>
({
windows
,
newWindow
,
context
,
fileUri
,
localWorkspaceResolver
:
workspaceResolver
}:
IBestWindowOrFolderOptions
<
W
>
):
W
|
undefined
{
if
(
!
newWindow
&&
fileUri
&&
(
context
===
OpenContext
.
DESKTOP
||
context
===
OpenContext
.
CLI
||
context
===
OpenContext
.
DOCK
))
{
const
windowOnFilePath
=
findWindowOnFilePath
(
windows
,
fileUri
,
workspaceResolver
);
if
(
windowOnFilePath
)
{
...
...
@@ -38,15 +38,15 @@ export function findBestWindowOrFolderForFile<W extends ISimpleWindow>({ windows
return
!
newWindow
?
getLastActiveWindow
(
windows
)
:
undefined
;
}
function
findWindowOnFilePath
<
W
extends
ISimpleWindow
>
(
windows
:
W
[],
fileUri
:
URI
,
w
orkspaceResolver
:
(
workspace
:
IWorkspaceIdentifier
)
=>
IResolvedWorkspace
|
null
):
W
|
null
{
function
findWindowOnFilePath
<
W
extends
ISimpleWindow
>
(
windows
:
W
[],
fileUri
:
URI
,
localW
orkspaceResolver
:
(
workspace
:
IWorkspaceIdentifier
)
=>
IResolvedWorkspace
|
null
):
W
|
null
{
// First check for windows with workspaces that have a parent folder of the provided path opened
for
(
const
window
of
windows
)
{
const
workspace
=
window
.
openedWorkspace
;
if
(
workspace
)
{
const
resolvedWorkspace
=
w
orkspaceResolver
(
workspace
);
const
resolvedWorkspace
=
localW
orkspaceResolver
(
workspace
);
if
(
resolvedWorkspace
)
{
// workspace c
p
uld be resolved: It's in the local file system
// workspace c
o
uld be resolved: It's in the local file system
if
(
resolvedWorkspace
.
folders
.
some
(
folder
=>
isEqualOrParent
(
fileUri
,
folder
.
uri
)))
{
return
window
;
}
...
...
src/vs/code/test/node/windowsFinder.test.ts
浏览文件 @
d77d7d29
...
...
@@ -24,7 +24,7 @@ function options(custom?: Partial<IBestWindowOrFolderOptions<ISimpleWindow>>): I
newWindow
:
false
,
context
:
OpenContext
.
CLI
,
codeSettingsFolder
:
'
_vscode
'
,
w
orkspaceResolver
:
workspace
=>
{
return
workspace
===
testWorkspace
?
{
id
:
testWorkspace
.
id
,
configPath
:
workspace
.
configPath
,
folders
:
toWorkspaceFolders
([{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_1_folder
'
)
},
{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_2_folder
'
)
}])
}
:
null
!
;
},
localW
orkspaceResolver
:
workspace
=>
{
return
workspace
===
testWorkspace
?
{
id
:
testWorkspace
.
id
,
configPath
:
workspace
.
configPath
,
folders
:
toWorkspaceFolders
([{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_1_folder
'
)
},
{
path
:
path
.
join
(
fixturesFolder
,
'
vscode_workspace_2_folder
'
)
}])
}
:
null
!
;
},
...
custom
};
}
...
...
src/vs/platform/environment/common/environment.ts
浏览文件 @
d77d7d29
...
...
@@ -109,7 +109,7 @@ export interface IEnvironmentService {
backupHome
:
string
;
backupWorkspacesPath
:
string
;
workspacesHome
:
string
;
untitledWorkspacesHome
:
URI
;
isExtensionDevelopment
:
boolean
;
disableExtensions
:
boolean
|
string
[];
...
...
src/vs/platform/environment/node/environmentService.ts
浏览文件 @
d77d7d29
...
...
@@ -135,7 +135,7 @@ export class EnvironmentService implements IEnvironmentService {
get
backupWorkspacesPath
():
string
{
return
path
.
join
(
this
.
backupHome
,
'
workspaces.json
'
);
}
@
memoize
get
workspacesHome
():
string
{
return
path
.
join
(
this
.
userDataPath
,
'
Workspaces
'
);
}
get
untitledWorkspacesHome
():
URI
{
return
URI
.
file
(
path
.
join
(
this
.
userDataPath
,
'
Workspaces
'
)
);
}
@
memoize
get
installSourcePath
():
string
{
return
path
.
join
(
this
.
userDataPath
,
'
installSource
'
);
}
...
...
src/vs/platform/history/electron-main/historyMainService.ts
浏览文件 @
d77d7d29
...
...
@@ -289,7 +289,7 @@ export class HistoryMainService implements IHistoryMainService {
type
:
'
custom
'
,
name
:
nls
.
localize
(
'
recentFolders
'
,
"
Recent Workspaces
"
),
items
:
arrays
.
coalesce
(
this
.
getRecentlyOpened
().
workspaces
.
slice
(
0
,
7
/* limit number of entries here */
).
map
(
workspace
=>
{
const
title
=
getSimpleWorkspaceLabel
(
workspace
,
this
.
environmentService
.
w
orkspacesHome
);
const
title
=
getSimpleWorkspaceLabel
(
workspace
,
this
.
environmentService
.
untitledW
orkspacesHome
);
let
description
;
let
args
;
if
(
isSingleFolderWorkspaceIdentifier
(
workspace
))
{
...
...
src/vs/platform/label/common/label.ts
浏览文件 @
d77d7d29
...
...
@@ -43,12 +43,12 @@ export interface ResourceLabelFormatting {
const
LABEL_SERVICE_ID
=
'
label
'
;
export
function
getSimpleWorkspaceLabel
(
workspace
:
IWorkspaceIdentifier
|
URI
,
workspaceHome
:
string
):
string
{
export
function
getSimpleWorkspaceLabel
(
workspace
:
IWorkspaceIdentifier
|
URI
,
workspaceHome
:
URI
):
string
{
if
(
isSingleFolderWorkspaceIdentifier
(
workspace
))
{
return
basename
(
workspace
);
}
// Workspace: Untitled
if
(
isEqualOrParent
(
workspace
.
configPath
,
URI
.
file
(
workspaceHome
)
))
{
if
(
isEqualOrParent
(
workspace
.
configPath
,
workspaceHome
))
{
return
localize
(
'
untitledWorkspace
'
,
"
Untitled (Workspace)
"
);
}
...
...
src/vs/platform/launch/electron-main/launchService.ts
浏览文件 @
d77d7d29
...
...
@@ -19,7 +19,6 @@ import { BrowserWindow } from 'electron';
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
hasArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
export
const
ID
=
'
launchService
'
;
export
const
ILaunchService
=
createDecorator
<
ILaunchService
>
(
ID
);
...
...
@@ -273,7 +272,7 @@ export class LaunchService implements ILaunchService {
}
else
if
(
window
.
openedWorkspace
)
{
// workspace folders can only be shown for local workspaces
const
workspaceConfigPath
=
window
.
openedWorkspace
.
configPath
;
const
resolvedWorkspace
=
workspaceConfigPath
.
scheme
===
Schemas
.
file
&&
this
.
workspacesMainService
.
resolveWorkspaceSync
(
workspaceConfigPath
.
fs
Path
);
const
resolvedWorkspace
=
this
.
workspacesMainService
.
resolveLocalWorkspaceSync
(
workspaceConfig
Path
);
if
(
resolvedWorkspace
)
{
const
rootFolders
=
resolvedWorkspace
.
folders
;
rootFolders
.
forEach
(
root
=>
{
...
...
src/vs/platform/workspaces/common/workspaces.ts
浏览文件 @
d77d7d29
...
...
@@ -88,7 +88,7 @@ export interface IWorkspacesMainService extends IWorkspacesService {
createUntitledWorkspaceSync
(
folders
?:
IWorkspaceFolderCreationData
[]):
IWorkspaceIdentifier
;
resolve
WorkspaceSync
(
path
:
string
):
IResolvedWorkspace
|
null
;
resolve
LocalWorkspaceSync
(
path
:
URI
):
IResolvedWorkspace
|
null
;
isUntitledWorkspace
(
workspace
:
IWorkspaceIdentifier
):
boolean
;
...
...
src/vs/platform/workspaces/electron-main/workspacesMainService.ts
浏览文件 @
d77d7d29
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
{
IWorkspacesMainService
,
IWorkspaceIdentifier
,
hasWorkspaceFileExtension
,
UNTITLED_WORKSPACE_NAME
,
IResolvedWorkspace
,
IStoredWorkspaceFolder
,
isStoredWorkspaceFolder
,
IWorkspaceFolderCreationData
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
isParent
}
from
'
vs/platform/files/common/files
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
join
,
dirname
}
from
'
path
'
;
import
{
mkdirp
,
writeFile
,
readFile
}
from
'
vs/base/node/pfs
'
;
...
...
@@ -21,7 +20,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
{
fsPath
,
dirname
as
resourcesDirname
}
from
'
vs/base/common/resources
'
;
import
{
fsPath
,
dirname
as
resourcesDirname
,
isEqualOrParent
,
joinPath
}
from
'
vs/base/common/resources
'
;
export
interface
IStoredWorkspace
{
folders
:
IStoredWorkspaceFolder
[];
...
...
@@ -31,7 +30,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
_serviceBrand
:
any
;
private
workspacesHome
:
string
;
private
readonly
untitledWorkspacesHome
:
URI
;
// local URI that contains all untitled workspaces
private
readonly
_onUntitledWorkspaceDeleted
=
this
.
_register
(
new
Emitter
<
IWorkspaceIdentifier
>
());
get
onUntitledWorkspaceDeleted
():
Event
<
IWorkspaceIdentifier
>
{
return
this
.
_onUntitledWorkspaceDeleted
.
event
;
}
...
...
@@ -42,26 +41,29 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
)
{
super
();
this
.
workspacesHome
=
environmentService
.
w
orkspacesHome
;
this
.
untitledWorkspacesHome
=
environmentService
.
untitledW
orkspacesHome
;
}
resolve
WorkspaceSync
(
path
:
string
):
IResolvedWorkspace
|
null
{
if
(
!
this
.
isWorkspacePath
(
path
))
{
resolve
LocalWorkspaceSync
(
uri
:
URI
):
IResolvedWorkspace
|
null
{
if
(
!
this
.
isWorkspacePath
(
uri
))
{
return
null
;
// does not look like a valid workspace config file
}
if
(
uri
.
scheme
!==
Schemas
.
file
)
{
return
null
;
}
let
contents
:
string
;
try
{
contents
=
readFileSync
(
p
ath
,
'
utf8
'
);
contents
=
readFileSync
(
uri
.
fsP
ath
,
'
utf8
'
);
}
catch
(
error
)
{
return
null
;
// invalid workspace
}
return
this
.
doResolveWorkspace
(
URI
.
file
(
path
)
,
contents
);
return
this
.
doResolveWorkspace
(
uri
,
contents
);
}
private
isWorkspacePath
(
path
:
string
):
boolean
{
return
this
.
isInsideWorkspacesHome
(
path
)
||
hasWorkspaceFileExtension
(
path
);
private
isWorkspacePath
(
uri
:
URI
):
boolean
{
return
this
.
isInsideWorkspacesHome
(
uri
)
||
hasWorkspaceFileExtension
(
uri
.
path
);
}
private
doResolveWorkspace
(
path
:
URI
,
contents
:
string
):
IResolvedWorkspace
|
null
{
...
...
@@ -98,36 +100,34 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
return
storedWorkspace
;
}
private
isInsideWorkspacesHome
(
path
:
string
):
boolean
{
return
is
Parent
(
path
,
this
.
environmentService
.
workspacesHome
,
!
isLinux
/* ignore case */
);
private
isInsideWorkspacesHome
(
path
:
URI
):
boolean
{
return
is
EqualOrParent
(
path
,
this
.
environmentService
.
untitledWorkspacesHome
);
}
createUntitledWorkspace
(
folders
?:
IWorkspaceFolderCreationData
[]):
Promise
<
IWorkspaceIdentifier
>
{
const
{
workspace
,
configParent
,
storedWorkspace
}
=
this
.
newUntitledWorkspace
(
folders
);
const
{
workspace
,
storedWorkspace
}
=
this
.
newUntitledWorkspace
(
folders
);
const
configPath
=
workspace
.
configPath
.
fsPath
;
return
mkdirp
(
configParent
).
then
(()
=>
{
return
writeFile
(
workspace
.
configPath
.
fs
Path
,
JSON
.
stringify
(
storedWorkspace
,
null
,
'
\t
'
)).
then
(()
=>
workspace
);
return
mkdirp
(
dirname
(
configPath
)
).
then
(()
=>
{
return
writeFile
(
config
Path
,
JSON
.
stringify
(
storedWorkspace
,
null
,
'
\t
'
)).
then
(()
=>
workspace
);
});
}
createUntitledWorkspaceSync
(
folders
?:
IWorkspaceFolderCreationData
[]):
IWorkspaceIdentifier
{
const
{
workspace
,
configParent
,
storedWorkspace
}
=
this
.
newUntitledWorkspace
(
folders
);
if
(
!
existsSync
(
this
.
workspacesHome
))
{
mkdirSync
(
this
.
workspacesHome
);
}
const
{
workspace
,
storedWorkspace
}
=
this
.
newUntitledWorkspace
(
folders
);
const
configPath
=
workspace
.
configPath
.
fsPath
;
mkdirSync
(
configParent
);
mkdirSync
(
dirname
(
configPath
),
{
recursive
:
true
}
);
writeFileAndFlushSync
(
workspace
.
configPath
.
fs
Path
,
JSON
.
stringify
(
storedWorkspace
,
null
,
'
\t
'
));
writeFileAndFlushSync
(
config
Path
,
JSON
.
stringify
(
storedWorkspace
,
null
,
'
\t
'
));
return
workspace
;
}
private
newUntitledWorkspace
(
folders
:
IWorkspaceFolderCreationData
[]
=
[]):
{
workspace
:
IWorkspaceIdentifier
,
configParent
:
string
,
storedWorkspace
:
IStoredWorkspace
}
{
private
newUntitledWorkspace
(
folders
:
IWorkspaceFolderCreationData
[]
=
[]):
{
workspace
:
IWorkspaceIdentifier
,
storedWorkspace
:
IStoredWorkspace
}
{
const
randomId
=
(
Date
.
now
()
+
Math
.
round
(
Math
.
random
()
*
1000
)).
toString
();
const
untitledWorkspaceConfigFolder
=
join
(
this
.
w
orkspacesHome
,
randomId
);
const
untitledWorkspaceConfigPath
=
join
(
untitledWorkspaceConfigFolder
,
UNTITLED_WORKSPACE_NAME
);
const
untitledWorkspaceConfigFolder
=
join
Path
(
this
.
untitledW
orkspacesHome
,
randomId
);
const
untitledWorkspaceConfigPath
=
join
Path
(
untitledWorkspaceConfigFolder
,
UNTITLED_WORKSPACE_NAME
);
const
storedWorkspace
:
IStoredWorkspace
=
{
folders
:
folders
.
map
(
folder
=>
{
...
...
@@ -136,7 +136,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
// File URI
if
(
folderResource
.
scheme
===
Schemas
.
file
)
{
storedWorkspace
=
{
path
:
massageFolderPathForWorkspace
(
fsPath
(
folderResource
),
URI
.
file
(
untitledWorkspaceConfigFolder
)
,
[])
};
storedWorkspace
=
{
path
:
massageFolderPathForWorkspace
(
fsPath
(
folderResource
),
untitledWorkspaceConfigFolder
,
[])
};
}
// Any URI
...
...
@@ -153,8 +153,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
};
return
{
workspace
:
this
.
getWorkspaceIdentifier
(
URI
.
file
(
untitledWorkspaceConfigPath
)),
configParent
:
untitledWorkspaceConfigFolder
,
workspace
:
this
.
getWorkspaceIdentifier
(
untitledWorkspaceConfigPath
),
storedWorkspace
};
}
...
...
@@ -176,7 +175,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
}
isUntitledWorkspace
(
workspace
:
IWorkspaceIdentifier
):
boolean
{
return
workspace
.
configPath
.
scheme
===
Schemas
.
file
&&
this
.
isInsideWorkspacesHome
(
fsPath
(
workspace
.
configPath
)
);
return
this
.
isInsideWorkspacesHome
(
workspace
.
configPath
);
}
saveWorkspaceAs
(
workspace
:
IWorkspaceIdentifier
,
targetConfigPath
:
string
):
Promise
<
IWorkspaceIdentifier
>
{
...
...
@@ -234,10 +233,10 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
getUntitledWorkspacesSync
():
IWorkspaceIdentifier
[]
{
let
untitledWorkspaces
:
IWorkspaceIdentifier
[]
=
[];
try
{
const
untitledWorkspacePaths
=
readdirSync
(
this
.
workspacesHome
).
map
(
folder
=>
join
(
this
.
w
orkspacesHome
,
folder
,
UNTITLED_WORKSPACE_NAME
));
const
untitledWorkspacePaths
=
readdirSync
(
this
.
untitledWorkspacesHome
.
fsPath
).
map
(
folder
=>
joinPath
(
this
.
untitledW
orkspacesHome
,
folder
,
UNTITLED_WORKSPACE_NAME
));
for
(
const
untitledWorkspacePath
of
untitledWorkspacePaths
)
{
const
workspace
=
this
.
getWorkspaceIdentifier
(
URI
.
file
(
untitledWorkspacePath
)
);
if
(
!
this
.
resolveWorkspaceSync
(
untitledWorkspacePath
))
{
const
workspace
=
this
.
getWorkspaceIdentifier
(
untitledWorkspacePath
);
if
(
!
this
.
resolve
Local
WorkspaceSync
(
untitledWorkspacePath
))
{
this
.
doDeleteUntitledWorkspaceSync
(
workspace
);
}
else
{
untitledWorkspaces
.
push
(
workspace
);
...
...
@@ -245,7 +244,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
}
}
catch
(
error
)
{
if
(
error
&&
error
.
code
!==
'
ENOENT
'
)
{
this
.
logService
.
warn
(
`Unable to read folders in
${
this
.
w
orkspacesHome
}
(
${
error
}
).`
);
this
.
logService
.
warn
(
`Unable to read folders in
${
this
.
untitledW
orkspacesHome
}
(
${
error
}
).`
);
}
}
return
untitledWorkspaces
;
...
...
src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts
浏览文件 @
d77d7d29
...
...
@@ -21,11 +21,11 @@ import { normalizeDriveLetter } from 'vs/base/common/labels';
suite
(
'
WorkspacesMainService
'
,
()
=>
{
const
parentDir
=
getRandomTestPath
(
os
.
tmpdir
(),
'
vsctests
'
,
'
workspacesservice
'
);
const
workspacesHome
=
path
.
join
(
parentDir
,
'
Workspaces
'
);
const
untitledWorkspacesHomePath
=
path
.
join
(
parentDir
,
'
Workspaces
'
);
class
TestEnvironmentService
extends
EnvironmentService
{
get
workspacesHome
():
string
{
return
workspacesHome
;
get
untitledWorkspacesHome
():
URI
{
return
URI
.
file
(
untitledWorkspacesHomePath
)
;
}
}
...
...
@@ -56,13 +56,13 @@ suite('WorkspacesMainService', () => {
service
=
new
TestWorkspacesMainService
(
environmentService
,
logService
);
// Delete any existing backups completely and then re-create it.
return
pfs
.
del
(
workspacesHome
,
os
.
tmpdir
()).
then
(()
=>
{
return
pfs
.
mkdirp
(
workspacesHome
);
return
pfs
.
del
(
untitledWorkspacesHomePath
,
os
.
tmpdir
()).
then
(()
=>
{
return
pfs
.
mkdirp
(
untitledWorkspacesHomePath
);
});
});
teardown
(()
=>
{
return
pfs
.
del
(
workspacesHome
,
os
.
tmpdir
());
return
pfs
.
del
(
untitledWorkspacesHomePath
,
os
.
tmpdir
());
});
function
assertPathEquals
(
p1
:
string
,
p2
):
void
{
...
...
@@ -173,20 +173,20 @@ suite('WorkspacesMainService', () => {
test
(
'
resolveWorkspaceSync
'
,
()
=>
{
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
workspace
=>
{
assert
.
ok
(
service
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
));
assert
.
ok
(
service
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
));
// make it a valid workspace path
const
newPath
=
path
.
join
(
path
.
dirname
(
workspace
.
configPath
.
fsPath
),
`workspace.
${
WORKSPACE_EXTENSION
}
`
);
fs
.
renameSync
(
workspace
.
configPath
.
fsPath
,
newPath
);
workspace
.
configPath
=
URI
.
file
(
newPath
);
const
resolved
=
service
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
);
const
resolved
=
service
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
);
assert
.
equal
(
2
,
resolved
!
.
folders
.
length
);
assertEqualURI
(
resolved
!
.
configPath
,
workspace
.
configPath
);
assert
.
ok
(
resolved
!
.
id
);
fs
.
writeFileSync
(
workspace
.
configPath
.
fsPath
,
JSON
.
stringify
({
something
:
'
something
'
}));
// invalid workspace
const
resolvedInvalid
=
service
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
);
const
resolvedInvalid
=
service
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
);
assert
.
ok
(
!
resolvedInvalid
);
});
});
...
...
@@ -195,7 +195,7 @@ suite('WorkspacesMainService', () => {
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
workspace
=>
{
fs
.
writeFileSync
(
workspace
.
configPath
.
fsPath
,
JSON
.
stringify
({
folders
:
[{
path
:
'
./ticino-playground/lib
'
}]
}));
const
resolved
=
service
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
);
const
resolved
=
service
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
);
assertEqualURI
(
resolved
!
.
folders
[
0
].
uri
,
URI
.
file
(
path
.
join
(
path
.
dirname
(
workspace
.
configPath
.
fsPath
),
'
ticino-playground
'
,
'
lib
'
)));
});
});
...
...
@@ -204,7 +204,7 @@ suite('WorkspacesMainService', () => {
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
workspace
=>
{
fs
.
writeFileSync
(
workspace
.
configPath
.
fsPath
,
JSON
.
stringify
({
folders
:
[{
path
:
'
./ticino-playground/lib/../other
'
}]
}));
const
resolved
=
service
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
);
const
resolved
=
service
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
);
assertEqualURI
(
resolved
!
.
folders
[
0
].
uri
,
URI
.
file
(
path
.
join
(
path
.
dirname
(
workspace
.
configPath
.
fsPath
),
'
ticino-playground
'
,
'
other
'
)));
});
});
...
...
@@ -213,7 +213,7 @@ suite('WorkspacesMainService', () => {
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
workspace
=>
{
fs
.
writeFileSync
(
workspace
.
configPath
.
fsPath
,
JSON
.
stringify
({
folders
:
[{
path
:
'
ticino-playground/lib
'
}]
}));
const
resolved
=
service
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
);
const
resolved
=
service
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
);
assertEqualURI
(
resolved
!
.
folders
[
0
].
uri
,
URI
.
file
(
path
.
join
(
path
.
dirname
(
workspace
.
configPath
.
fsPath
),
'
ticino-playground
'
,
'
lib
'
)));
});
});
...
...
@@ -222,7 +222,7 @@ suite('WorkspacesMainService', () => {
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
workspace
=>
{
fs
.
writeFileSync
(
workspace
.
configPath
.
fsPath
,
'
{ "folders": [ { "path": "./ticino-playground/lib" } , ] }
'
);
// trailing comma
const
resolved
=
service
.
resolve
WorkspaceSync
(
workspace
.
configPath
.
fs
Path
);
const
resolved
=
service
.
resolve
LocalWorkspaceSync
(
workspace
.
config
Path
);
assertEqualURI
(
resolved
!
.
folders
[
0
].
uri
,
URI
.
file
(
path
.
join
(
path
.
dirname
(
workspace
.
configPath
.
fsPath
),
'
ticino-playground
'
,
'
lib
'
)));
});
});
...
...
@@ -345,7 +345,7 @@ suite('WorkspacesMainService', () => {
test
(
'
getUntitledWorkspaceSync
'
,
()
=>
{
let
untitled
=
service
.
getUntitledWorkspacesSync
();
assert
.
equal
(
0
,
untitled
.
length
);
assert
.
equal
(
untitled
.
length
,
0
);
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
untitledOne
=>
{
assert
.
ok
(
fs
.
existsSync
(
untitledOne
.
configPath
.
fsPath
));
...
...
src/vs/workbench/services/dialogs/electron-browser/dialogService.ts
浏览文件 @
d77d7d29
...
...
@@ -18,7 +18,6 @@ import { URI } from 'vs/base/common/uri';
import
{
REMOTE_HOST_SCHEME
}
from
'
vs/platform/remote/common/remoteHosts
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
isParent
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
RemoteFileDialog
}
from
'
vs/workbench/services/dialogs/electron-browser/remoteFileDialog
'
;
...
...
@@ -196,9 +195,9 @@ export class FileDialogService implements IFileDialogService {
defaultWorkspacePath
(
schemeFilter
:
string
):
URI
|
undefined
{
// Check for current workspace config file first...
if
(
schemeFilter
===
Schemas
.
file
&&
this
.
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
WORKSPACE
)
{
if
(
this
.
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
WORKSPACE
)
{
const
configuration
=
this
.
contextService
.
getWorkspace
().
configuration
;
if
(
configuration
&&
!
isUntitledWorkspace
(
configuration
.
fsPath
,
this
.
environmentService
))
{
if
(
configuration
&&
!
isUntitledWorkspace
(
configuration
,
this
.
environmentService
))
{
return
resources
.
dirname
(
configuration
)
||
undefined
;
}
}
...
...
@@ -340,6 +339,6 @@ export class RemoteFileDialogService extends FileDialogService {
}
}
function
isUntitledWorkspace
(
path
:
string
,
environmentService
:
IEnvironmentService
):
boolean
{
return
isParent
(
path
,
environmentService
.
workspacesHome
,
!
isLinux
/* ignore case */
);
function
isUntitledWorkspace
(
path
:
URI
,
environmentService
:
IEnvironmentService
):
boolean
{
return
resources
.
isEqualOrParent
(
path
,
environmentService
.
untitledWorkspacesHome
);
}
\ No newline at end of file
src/vs/workbench/services/label/common/labelService.ts
浏览文件 @
d77d7d29
...
...
@@ -186,7 +186,7 @@ export class LabelService implements ILabelService {
}
// Workspace: Untitled
if
(
isEqualOrParent
(
workspace
.
configPath
,
URI
.
file
(
this
.
environmentService
.
workspacesHome
)
))
{
if
(
isEqualOrParent
(
workspace
.
configPath
,
this
.
environmentService
.
untitledWorkspacesHome
))
{
return
localize
(
'
untitledWorkspace
'
,
"
Untitled (Workspace)
"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录