Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b7e8dcbf
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,发现更多精彩内容 >>
提交
b7e8dcbf
编写于
12月 06, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Opening a file always opens two windows (fixes #16574)
上级
a8d5b928
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
47 deletion
+47
-47
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+2
-2
src/vs/platform/backup/common/backup.ts
src/vs/platform/backup/common/backup.ts
+2
-2
src/vs/platform/backup/electron-main/backupMainService.ts
src/vs/platform/backup/electron-main/backupMainService.ts
+4
-4
src/vs/platform/backup/test/electron-main/backupMainService.test.ts
...tform/backup/test/electron-main/backupMainService.test.ts
+39
-39
未找到文件。
src/vs/code/electron-main/windows.ts
浏览文件 @
b7e8dcbf
...
...
@@ -323,11 +323,11 @@ export class WindowsManager implements IWindowsMainService {
}
let
foldersToOpen
=
arrays
.
distinct
(
iPathsToOpen
.
filter
(
iPath
=>
iPath
.
workspacePath
&&
!
iPath
.
filePath
).
map
(
iPath
=>
iPath
.
workspacePath
),
folder
=>
platform
.
isLinux
?
folder
:
folder
.
toLowerCase
());
// prevent duplicates
let
foldersToRestore
=
(
openConfig
.
initialStartup
&&
!
openConfig
.
cli
.
extensionDevelopmentPath
)
?
this
.
backupService
.
workspaceBackupPaths
:
[];
let
foldersToRestore
=
(
openConfig
.
initialStartup
&&
!
openConfig
.
cli
.
extensionDevelopmentPath
)
?
this
.
backupService
.
getWorkspaceBackupPaths
()
:
[];
let
filesToOpen
:
IPath
[]
=
[];
let
filesToDiff
:
IPath
[]
=
[];
let
emptyToOpen
=
iPathsToOpen
.
filter
(
iPath
=>
!
iPath
.
workspacePath
&&
!
iPath
.
filePath
);
let
emptyToRestore
=
(
openConfig
.
initialStartup
&&
!
openConfig
.
cli
.
extensionDevelopmentPath
)
?
this
.
backupService
.
emptyWorkspaceBackupPaths
:
[];
let
emptyToRestore
=
(
openConfig
.
initialStartup
&&
!
openConfig
.
cli
.
extensionDevelopmentPath
)
?
this
.
backupService
.
getEmptyWorkspaceBackupPaths
()
:
[];
let
filesToCreate
=
iPathsToOpen
.
filter
(
iPath
=>
!!
iPath
.
filePath
&&
iPath
.
createFilePath
);
// Diff mode needs special care
...
...
src/vs/platform/backup/common/backup.ts
浏览文件 @
b7e8dcbf
...
...
@@ -17,8 +17,8 @@ export const IBackupService = createDecorator<IBackupService>('backupService');
export
interface
IBackupMainService
extends
IBackupService
{
_serviceBrand
:
any
;
workspaceBackupPaths
:
string
[];
emptyWorkspaceBackupPaths
:
string
[];
getWorkspaceBackupPaths
()
:
string
[];
getEmptyWorkspaceBackupPaths
()
:
string
[];
registerWindowForBackupsSync
(
windowId
:
number
,
isEmptyWorkspace
:
boolean
,
backupFolder
?:
string
,
workspacePath
?:
string
):
void
;
}
...
...
src/vs/platform/backup/electron-main/backupMainService.ts
浏览文件 @
b7e8dcbf
...
...
@@ -34,12 +34,12 @@ export class BackupMainService implements IBackupMainService {
this
.
loadSync
();
}
public
get
w
orkspaceBackupPaths
():
string
[]
{
return
this
.
backups
.
folderWorkspaces
;
public
get
W
orkspaceBackupPaths
():
string
[]
{
return
this
.
backups
.
folderWorkspaces
.
slice
(
0
);
// return a copy
}
public
get
e
mptyWorkspaceBackupPaths
():
string
[]
{
return
this
.
backups
.
emptyWorkspaces
;
public
get
E
mptyWorkspaceBackupPaths
():
string
[]
{
return
this
.
backups
.
emptyWorkspaces
.
slice
(
0
);
// return a copy
}
public
getBackupPath
(
windowId
:
number
):
TPromise
<
string
>
{
...
...
src/vs/platform/backup/test/electron-main/backupMainService.test.ts
浏览文件 @
b7e8dcbf
...
...
@@ -80,7 +80,7 @@ suite('BackupMainService', () => {
service
.
registerWindowForBackupsSync
(
1
,
false
,
null
,
fooFile
.
fsPath
);
service
.
registerWindowForBackupsSync
(
2
,
false
,
null
,
barFile
.
fsPath
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
// 2) backup workspace path exists with empty contents within
fs
.
mkdirSync
(
service
.
toBackupPath
(
fooFile
.
fsPath
));
...
...
@@ -88,7 +88,7 @@ suite('BackupMainService', () => {
service
.
registerWindowForBackupsSync
(
1
,
false
,
null
,
fooFile
.
fsPath
);
service
.
registerWindowForBackupsSync
(
2
,
false
,
null
,
barFile
.
fsPath
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
assert
.
ok
(
!
fs
.
exists
(
service
.
toBackupPath
(
fooFile
.
fsPath
)));
assert
.
ok
(
!
fs
.
exists
(
service
.
toBackupPath
(
barFile
.
fsPath
)));
...
...
@@ -100,7 +100,7 @@ suite('BackupMainService', () => {
service
.
registerWindowForBackupsSync
(
1
,
false
,
null
,
fooFile
.
fsPath
);
service
.
registerWindowForBackupsSync
(
2
,
false
,
null
,
barFile
.
fsPath
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
assert
.
ok
(
!
fs
.
exists
(
service
.
toBackupPath
(
fooFile
.
fsPath
)));
assert
.
ok
(
!
fs
.
exists
(
service
.
toBackupPath
(
barFile
.
fsPath
)));
...
...
@@ -111,101 +111,101 @@ suite('BackupMainService', () => {
fs
.
mkdirSync
(
service
.
toBackupPath
(
barFile
.
fsPath
));
fs
.
mkdirSync
(
fileBackups
);
service
.
registerWindowForBackupsSync
(
1
,
false
,
null
,
fooFile
.
fsPath
);
assert
.
equal
(
service
.
workspaceBackupPaths
.
length
,
1
);
assert
.
equal
(
service
.
emptyWorkspaceBackupPaths
.
length
,
0
);
assert
.
equal
(
service
.
getWorkspaceBackupPaths
()
.
length
,
1
);
assert
.
equal
(
service
.
getEmptyWorkspaceBackupPaths
()
.
length
,
0
);
fs
.
writeFileSync
(
path
.
join
(
fileBackups
,
'
backup.txt
'
),
''
);
service
.
loadSync
();
assert
.
equal
(
service
.
workspaceBackupPaths
.
length
,
0
);
assert
.
equal
(
service
.
emptyWorkspaceBackupPaths
.
length
,
1
);
assert
.
equal
(
service
.
getWorkspaceBackupPaths
()
.
length
,
0
);
assert
.
equal
(
service
.
getEmptyWorkspaceBackupPaths
()
.
length
,
1
);
done
();
});
suite
(
'
loadSync
'
,
()
=>
{
test
(
'
workspaceBackupPaths
should return [] when workspaces.json doesn
\'
t exist
'
,
()
=>
{
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
test
(
'
getWorkspaceBackupPaths()
should return [] when workspaces.json doesn
\'
t exist
'
,
()
=>
{
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
});
test
(
'
workspaceBackupPaths
should return [] when workspaces.json is not properly formed JSON
'
,
()
=>
{
test
(
'
getWorkspaceBackupPaths()
should return [] when workspaces.json is not properly formed JSON
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
''
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{]
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
foo
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
});
test
(
'
workspaceBackupPaths
should return [] when folderWorkspaces in workspaces.json is absent
'
,
()
=>
{
test
(
'
getWorkspaceBackupPaths()
should return [] when folderWorkspaces in workspaces.json is absent
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
});
test
(
'
workspaceBackupPaths
should return [] when folderWorkspaces in workspaces.json is not a string array
'
,
()
=>
{
test
(
'
getWorkspaceBackupPaths()
should return [] when folderWorkspaces in workspaces.json is not a string array
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{"foo": ["bar"]}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{"foo": []}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{"foo": "bar"}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":"foo"}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":1}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[]);
});
test
(
'
emptyWorkspaceBackupPaths
should return [] when workspaces.json doesn
\'
t exist
'
,
()
=>
{
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
test
(
'
getEmptyWorkspaceBackupPaths()
should return [] when workspaces.json doesn
\'
t exist
'
,
()
=>
{
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
});
test
(
'
emptyWorkspaceBackupPaths
should return [] when workspaces.json is not properly formed JSON
'
,
()
=>
{
test
(
'
getEmptyWorkspaceBackupPaths()
should return [] when workspaces.json is not properly formed JSON
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
''
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{]
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
foo
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
});
test
(
'
emptyWorkspaceBackupPaths
should return [] when folderWorkspaces in workspaces.json is absent
'
,
()
=>
{
test
(
'
getEmptyWorkspaceBackupPaths()
should return [] when folderWorkspaces in workspaces.json is absent
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
});
test
(
'
emptyWorkspaceBackupPaths
should return [] when folderWorkspaces in workspaces.json is not a string array
'
,
()
=>
{
test
(
'
getEmptyWorkspaceBackupPaths()
should return [] when folderWorkspaces in workspaces.json is not a string array
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"emptyWorkspaces":{}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"emptyWorkspaces":{"foo": ["bar"]}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"emptyWorkspaces":{"foo": []}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"emptyWorkspaces":{"foo": "bar"}}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"emptyWorkspaces":"foo"}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"emptyWorkspaces":1}
'
);
service
.
loadSync
();
assert
.
deepEqual
(
service
.
emptyWorkspaceBackupPaths
,
[]);
assert
.
deepEqual
(
service
.
getEmptyWorkspaceBackupPaths
()
,
[]);
});
});
...
...
@@ -232,10 +232,10 @@ suite('BackupMainService', () => {
});
suite
(
'
registerWindowForBackups
'
,
()
=>
{
test
(
'
push
WorkspaceBackupPaths
Sync should persist paths to workspaces.json
'
,
()
=>
{
test
(
'
push
getWorkspaceBackupPaths()
Sync should persist paths to workspaces.json
'
,
()
=>
{
service
.
registerWindowForBackupsSync
(
1
,
false
,
null
,
fooFile
.
fsPath
);
service
.
registerWindowForBackupsSync
(
2
,
false
,
null
,
barFile
.
fsPath
);
assert
.
deepEqual
(
service
.
workspaceBackupPaths
,
[
fooFile
.
fsPath
,
barFile
.
fsPath
]);
assert
.
deepEqual
(
service
.
getWorkspaceBackupPaths
()
,
[
fooFile
.
fsPath
,
barFile
.
fsPath
]);
pfs
.
readFile
(
backupWorkspacesPath
,
'
utf-8
'
).
then
(
buffer
=>
{
const
json
=
<
IBackupWorkspacesFormat
>
JSON
.
parse
(
buffer
);
assert
.
deepEqual
(
json
.
folderWorkspaces
,
[
fooFile
.
fsPath
,
barFile
.
fsPath
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录