Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
10aa7095
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 搜索 >>
提交
10aa7095
编写于
10月 14, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disable hot exit on empty workspaces, fix uncaught exceptions
上级
c280e0ca
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
17 deletion
+82
-17
src/vs/platform/backup/node/backupService.ts
src/vs/platform/backup/node/backupService.ts
+33
-2
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+11
-9
src/vs/workbench/services/files/node/fileService.ts
src/vs/workbench/services/files/node/fileService.ts
+36
-5
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+2
-1
未找到文件。
src/vs/platform/backup/node/backupService.ts
浏览文件 @
10aa7095
...
...
@@ -32,9 +32,17 @@ export class BackupService implements IBackupService {
@
IWorkspaceContextService
contextService
?:
IWorkspaceContextService
)
{
// IWorkspaceContextService will not exist on the main process
if
(
contextService
)
{
this
.
workspaceResource
=
contextService
.
getWorkspace
().
resource
;
if
(
!
contextService
)
{
return
;
}
// Hot exit is disabled for empty workspaces
const
workspace
=
contextService
.
getWorkspace
();
if
(
!
workspace
)
{
return
;
}
this
.
workspaceResource
=
workspace
.
resource
;
}
public
getWorkspaceBackupPaths
():
string
[]
{
...
...
@@ -52,6 +60,10 @@ export class BackupService implements IBackupService {
public
pushWorkspaceBackupPaths
(
workspaces
:
string
[]):
void
{
this
.
load
();
workspaces
.
forEach
(
workspace
=>
{
// Hot exit is disabled for empty workspaces
if
(
!
workspace
)
{
return
;
}
if
(
!
this
.
fileContent
.
folderWorkspaces
[
workspace
])
{
this
.
fileContent
.
folderWorkspaces
[
workspace
]
=
[];
}
...
...
@@ -74,6 +86,11 @@ export class BackupService implements IBackupService {
}
public
getWorkspaceUntitledFileBackups
(
workspace
:
string
):
string
[]
{
// Hot exit is disabled for empty workspaces
if
(
!
this
.
workspaceResource
)
{
return
;
}
const
workspaceHash
=
crypto
.
createHash
(
'
md5
'
).
update
(
this
.
workspaceResource
.
fsPath
).
digest
(
'
hex
'
);
const
untitledDir
=
path
.
join
(
this
.
environmentService
.
backupHome
,
workspaceHash
,
'
untitled
'
);
try
{
...
...
@@ -87,6 +104,10 @@ export class BackupService implements IBackupService {
}
public
getBackupResource
(
resource
:
Uri
):
Uri
{
// Hot exit is disabled for empty workspaces
if
(
!
this
.
workspaceResource
)
{
return
;
}
const
workspaceHash
=
crypto
.
createHash
(
'
md5
'
).
update
(
this
.
workspaceResource
.
fsPath
).
digest
(
'
hex
'
);
const
backupName
=
crypto
.
createHash
(
'
md5
'
).
update
(
resource
.
fsPath
).
digest
(
'
hex
'
);
...
...
@@ -96,6 +117,11 @@ export class BackupService implements IBackupService {
}
public
registerResourceForBackup
(
resource
:
Uri
):
void
{
// Hot exit is disabled for empty workspaces
if
(
!
this
.
workspaceResource
)
{
return
;
}
this
.
load
();
if
(
arrays
.
contains
(
this
.
fileContent
.
folderWorkspaces
[
this
.
workspaceResource
.
fsPath
],
resource
.
fsPath
))
{
return
;
...
...
@@ -105,6 +131,11 @@ export class BackupService implements IBackupService {
}
public
deregisterResourceForBackup
(
resource
:
Uri
):
void
{
// Hot exit is disabled for empty workspaces
if
(
!
this
.
workspaceResource
)
{
return
;
}
this
.
load
();
this
.
fileContent
.
folderWorkspaces
[
this
.
workspaceResource
.
fsPath
]
=
this
.
fileContent
.
folderWorkspaces
[
this
.
workspaceResource
.
fsPath
].
filter
(
value
=>
value
!==
resource
.
fsPath
);
this
.
save
();
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
10aa7095
...
...
@@ -172,20 +172,22 @@ export class Workbench implements IPartService {
serviceCollection
};
// Restore any backups if they exist
options
.
filesToRestore
=
this
.
backupService
.
getWorkspaceTextFilesWithBackups
(
workspace
.
resource
.
fsPath
).
map
(
filePath
=>
{
return
{
resource
:
Uri
.
file
(
filePath
),
options
:
{
pinned
:
true
}
};
});
options
.
untitledFilesToRestore
=
this
.
backupService
.
getWorkspaceUntitledFileBackups
(
workspace
.
resource
.
fsPath
).
map
(
untitledFilePath
=>
{
return
{
resource
:
Uri
.
file
(
untitledFilePath
),
options
:
{
pinned
:
true
}
};
});
// Restore any backups if they exist for this workspace (empty workspaces are not supported yet)
if
(
workspace
)
{
options
.
filesToRestore
=
this
.
backupService
.
getWorkspaceTextFilesWithBackups
(
workspace
.
resource
.
fsPath
).
map
(
filePath
=>
{
return
{
resource
:
Uri
.
file
(
filePath
),
options
:
{
pinned
:
true
}
};
});
options
.
untitledFilesToRestore
=
this
.
backupService
.
getWorkspaceUntitledFileBackups
(
workspace
.
resource
.
fsPath
).
map
(
untitledFilePath
=>
{
return
{
resource
:
Uri
.
file
(
untitledFilePath
),
options
:
{
pinned
:
true
}
};
});
}
this
.
hasFilesToCreateOpenOrDiff
=
(
options
.
filesToCreate
&&
options
.
filesToCreate
.
length
>
0
)
||
(
options
.
filesToOpen
&&
options
.
filesToOpen
.
length
>
0
)
||
(
options
.
filesToDiff
&&
options
.
filesToDiff
.
length
>
0
)
||
(
options
.
filesToRestore
.
length
>
0
)
||
(
options
.
untitledFilesToRestore
.
length
>
0
);
(
options
.
filesToRestore
&&
options
.
filesToRestore
.
length
>
0
)
||
(
options
.
untitledFilesToRestore
&&
options
.
untitledFilesToRestore
.
length
>
0
);
this
.
toDispose
=
[];
this
.
toShutdown
=
[];
...
...
src/vs/workbench/services/files/node/fileService.ts
浏览文件 @
10aa7095
...
...
@@ -463,17 +463,36 @@ export class FileService implements IFileService {
this
.
backupService
.
registerResourceForBackup
(
resource
);
}
const
backupResource
=
this
.
getBackupPath
(
resource
);
// Hot exit is disabled for empty workspaces
if
(
!
backupResource
)
{
return
TPromise
.
as
(
null
);
}
console
.
log
(
`Backing up to
${
backupResource
.
fsPath
}
`
);
return
this
.
updateContent
(
backupResource
,
content
);
}
public
discardBackup
(
resource
:
uri
):
TPromise
<
void
>
{
this
.
backupService
.
deregisterResourceForBackup
(
resource
);
return
this
.
del
(
this
.
getBackupPath
(
resource
));
const
backupResource
=
this
.
getBackupPath
(
resource
);
// Hot exit is disabled for empty workspaces
if
(
!
backupResource
)
{
return
TPromise
.
as
(
null
);
}
return
this
.
del
(
backupResource
);
}
public
discardBackups
():
TPromise
<
void
>
{
return
this
.
del
(
uri
.
file
(
this
.
getBackupRoot
()));
// Hot exit is disabled for empty workspaces
const
backupRootPath
=
this
.
getBackupRootPath
();
if
(
!
backupRootPath
)
{
return
TPromise
.
as
(
void
0
);
}
return
this
.
del
(
uri
.
file
(
backupRootPath
));
}
public
isHotExitEnabled
():
boolean
{
...
...
@@ -483,13 +502,25 @@ export class FileService implements IFileService {
// Helpers
private
getBackupPath
(
resource
:
uri
):
uri
{
// Hot exit is disabled for empty workspaces
const
backupRootPath
=
this
.
getBackupRootPath
();
if
(
!
backupRootPath
)
{
return
null
;
}
const
backupName
=
crypto
.
createHash
(
'
md5
'
).
update
(
resource
.
fsPath
).
digest
(
'
hex
'
);
const
backupPath
=
paths
.
join
(
this
.
getBackupRoot
()
,
resource
.
scheme
,
backupName
);
const
backupPath
=
paths
.
join
(
backupRootPath
,
resource
.
scheme
,
backupName
);
return
uri
.
file
(
backupPath
);
}
private
getBackupRoot
():
string
{
let
workspaceHash
=
crypto
.
createHash
(
'
md5
'
).
update
(
this
.
contextService
.
getWorkspace
().
resource
.
fsPath
).
digest
(
'
hex
'
);
private
getBackupRootPath
():
string
{
// Hot exit is disabled for empty workspaces
const
workspace
=
this
.
contextService
.
getWorkspace
();
if
(
!
workspace
)
{
return
null
;
}
const
workspaceHash
=
crypto
.
createHash
(
'
md5
'
).
update
(
workspace
.
resource
.
fsPath
).
digest
(
'
hex
'
);
return
paths
.
join
(
this
.
environmentService
.
userDataPath
,
'
Backups
'
,
workspaceHash
);
}
...
...
src/vs/workbench/services/textfile/browser/textFileService.ts
浏览文件 @
10aa7095
...
...
@@ -231,7 +231,8 @@ export abstract class TextFileService implements ITextFileService {
this
.
saveAll
().
done
(
null
,
errors
.
onUnexpectedError
);
}
this
.
configuredHotExit
=
configuration
&&
configuration
.
files
&&
configuration
.
files
.
hotExit
;
// Hot exit is disabled for empty workspaces
this
.
configuredHotExit
=
this
.
contextService
.
getWorkspace
()
&&
configuration
&&
configuration
.
files
&&
configuration
.
files
.
hotExit
;
// Check for change in files associations
const
filesAssociation
=
configuration
&&
configuration
.
files
&&
configuration
.
files
.
associations
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录