Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
28d894e8
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
28d894e8
编写于
12月 13, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Hot Exit: opens needless untitled file when restoring backups (fixes #16821)
上级
a826f536
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
11 deletion
+126
-11
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+87
-1
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+11
-3
src/vs/workbench/services/backup/common/backup.ts
src/vs/workbench/services/backup/common/backup.ts
+5
-0
src/vs/workbench/services/backup/node/backupFileService.ts
src/vs/workbench/services/backup/node/backupFileService.ts
+16
-3
src/vs/workbench/services/backup/test/backupFileService.test.ts
.../workbench/services/backup/test/backupFileService.test.ts
+7
-4
未找到文件。
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
28d894e8
...
...
@@ -48,7 +48,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
IWindowsService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IWindowsService
,
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
export
const
TestWorkspace
:
IWorkspace
=
{
resource
:
URI
.
file
(
'
C:
\\
testWorkspace
'
),
...
...
@@ -625,6 +625,11 @@ export const TestFileService = {
export
class
TestBackupFileService
implements
IBackupFileService
{
public
_serviceBrand
:
any
;
public
hasBackups
():
TPromise
<
boolean
>
{
return
TPromise
.
as
(
false
);
}
public
hasBackup
(
resource
:
URI
):
TPromise
<
boolean
>
{
return
TPromise
.
as
(
false
);
}
...
...
@@ -672,6 +677,87 @@ export class TestBackupFileService implements IBackupFileService {
}
};
export
class
TestWindowService
implements
IWindowService
{
public
_serviceBrand
:
any
;
getCurrentWindowId
():
number
{
return
0
;
}
openFileFolderPicker
(
forceNewWindow
?:
boolean
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
openFilePicker
(
forceNewWindow
?:
boolean
,
path
?:
string
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
openFolderPicker
(
forceNewWindow
?:
boolean
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
reloadWindow
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
openDevTools
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
toggleDevTools
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
closeFolder
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
toggleFullScreen
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
setRepresentedFilename
(
fileName
:
string
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
addToRecentlyOpen
(
paths
:
{
path
:
string
,
isFile
?:
boolean
}[]):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
removeFromRecentlyOpen
(
paths
:
string
[]):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
getRecentlyOpen
():
TPromise
<
{
files
:
string
[];
folders
:
string
[];
}
>
{
return
TPromise
.
as
(
void
0
);
}
focusWindow
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
setDocumentEdited
(
flag
:
boolean
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
toggleMenuBar
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
isMaximized
():
TPromise
<
boolean
>
{
return
TPromise
.
as
(
void
0
);
}
maximizeWindow
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
unmaximizeWindow
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
}
export
class
TestLifecycleService
implements
ILifecycleService
{
public
_serviceBrand
:
any
;
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
28d894e8
...
...
@@ -149,6 +149,7 @@ export class Workbench implements IPartService {
private
viewletService
:
IViewletService
;
private
contextKeyService
:
IContextKeyService
;
private
keybindingService
:
IKeybindingService
;
private
backupFileService
:
IBackupFileService
;
private
configurationEditingService
:
IConfigurationEditingService
;
private
titlebarPart
:
TitlebarPart
;
private
activitybarPart
:
ActivitybarPart
;
...
...
@@ -387,7 +388,13 @@ export class Workbench implements IPartService {
// Empty workbench: some first time users will not have an untiled file; returning users will always have one
else
if
(
!
this
.
workbenchParams
.
workspace
&&
this
.
telemetryService
.
getExperiments
().
openUntitledFile
)
{
return
TPromise
.
as
([{
input
:
this
.
untitledEditorService
.
createOrGet
()
}]);
return
this
.
backupFileService
.
hasBackups
().
then
(
hasBackups
=>
{
if
(
hasBackups
)
{
return
TPromise
.
as
([]);
// do not open any empty untitled file if we have backups to restore
}
return
TPromise
.
as
([{
input
:
this
.
untitledEditorService
.
createOrGet
()
}]);
});
}
return
TPromise
.
as
([]);
...
...
@@ -462,8 +469,8 @@ export class Workbench implements IPartService {
serviceCollection
.
set
(
IHistoryService
,
new
SyncDescriptor
(
HistoryService
));
// Backup File Service
const
workspace
=
this
.
contextService
.
getWorkspace
(
);
serviceCollection
.
set
(
IBackupFileService
,
this
.
instantiationService
.
createInstance
(
BackupFileService
,
this
.
windowService
.
getCurrentWindowId
())
);
this
.
backupFileService
=
this
.
instantiationService
.
createInstance
(
BackupFileService
);
serviceCollection
.
set
(
IBackupFileService
,
this
.
backupFileService
);
// Text File Service
serviceCollection
.
set
(
ITextFileService
,
new
SyncDescriptor
(
TextFileService
));
...
...
@@ -479,6 +486,7 @@ export class Workbench implements IPartService {
serviceCollection
.
set
(
IConfigurationEditingService
,
this
.
configurationEditingService
);
// Configuration Resolver
const
workspace
=
this
.
contextService
.
getWorkspace
();
serviceCollection
.
set
(
IConfigurationResolverService
,
new
SyncDescriptor
(
ConfigurationResolverService
,
workspace
?
workspace
.
resource
:
null
,
process
.
env
));
// Quick open service (quick open controller)
...
...
src/vs/workbench/services/backup/common/backup.ts
浏览文件 @
28d894e8
...
...
@@ -22,6 +22,11 @@ export const BACKUP_FILE_UPDATE_OPTIONS: IUpdateContentOptions = { encoding: 'ut
export
interface
IBackupFileService
{
_serviceBrand
:
any
;
/**
* Finds out if there are any backups stored.
*/
hasBackups
():
TPromise
<
boolean
>
;
/**
* Loads the backup resource for a particular resource within the current workspace.
*
...
...
src/vs/workbench/services/backup/node/backupFileService.ts
浏览文件 @
28d894e8
...
...
@@ -17,6 +17,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
readToMatchingString
}
from
'
vs/base/node/stream
'
;
import
{
IRawTextContent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
export
interface
IBackupFilesModel
{
resolve
(
backupRoot
:
string
):
TPromise
<
IBackupFilesModel
>
;
...
...
@@ -25,6 +26,7 @@ export interface IBackupFilesModel {
has
(
resource
:
Uri
,
versionId
?:
number
):
boolean
;
get
():
Uri
[];
remove
(
resource
:
Uri
):
void
;
count
():
number
;
clear
():
void
;
}
...
...
@@ -55,6 +57,10 @@ export class BackupFilesModel implements IBackupFilesModel {
this
.
cache
[
resource
.
toString
()]
=
versionId
;
}
public
count
():
number
{
return
Object
.
keys
(
this
.
cache
).
length
;
}
public
has
(
resource
:
Uri
,
versionId
?:
number
):
boolean
{
const
cachedVersionId
=
this
.
cache
[
resource
.
toString
()];
if
(
typeof
cachedVersionId
!==
'
number
'
)
{
...
...
@@ -91,12 +97,12 @@ export class BackupFileService implements IBackupFileService {
private
ready
:
TPromise
<
IBackupFilesModel
>
;
constructor
(
windowId
:
number
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IFileService
private
fileService
:
IFileService
,
@
IWindowService
windowService
:
IWindowService
,
@
IBackupService
private
backupService
:
IBackupService
)
{
this
.
ready
=
this
.
init
(
window
Id
);
this
.
ready
=
this
.
init
(
window
Service
.
getCurrentWindowId
()
);
}
private
get
backupEnabled
():
boolean
{
...
...
@@ -112,10 +118,17 @@ export class BackupFileService implements IBackupFileService {
return
this
.
backupService
.
getBackupPath
(
windowId
).
then
(
backupPath
=>
{
this
.
backupWorkspacePath
=
backupPath
;
return
model
.
resolve
(
this
.
backupWorkspacePath
);
});
}
public
hasBackups
():
TPromise
<
boolean
>
{
return
this
.
ready
.
then
(
model
=>
{
return
model
.
count
()
>
0
;
});
}
public
hasBackup
(
resource
:
Uri
):
TPromise
<
boolean
>
{
return
this
.
ready
.
then
(
model
=>
{
const
backupResource
=
this
.
getBackupResource
(
resource
);
...
...
@@ -216,4 +229,4 @@ export class BackupFileService implements IBackupFileService {
return
crypto
.
createHash
(
'
md5
'
).
update
(
caseAwarePath
).
digest
(
'
hex
'
);
}
}
\ No newline at end of file
}
src/vs/workbench/services/backup/test/backupFileService.test.ts
浏览文件 @
28d894e8
...
...
@@ -22,7 +22,7 @@ import { parseArgs } from 'vs/platform/environment/node/argv';
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IRawTextContent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TestWindowService
}
from
'
vs/test/utils/servicesTestUtils
'
;
class
TestEnvironmentService
extends
EnvironmentService
{
constructor
(
private
_backupHome
:
string
,
private
_backupWorkspacesPath
:
string
)
{
...
...
@@ -56,7 +56,7 @@ class TestBackupFileService extends BackupFileService {
getBackupPath
:
()
=>
TPromise
.
as
(
workspaceBackupPath
)
};
super
(
1
,
environmentService
,
fileService
,
backupService
);
super
(
environmentService
,
fileService
,
new
TestWindowService
()
,
backupService
);
}
public
getBackupResource
(
resource
:
Uri
):
Uri
{
...
...
@@ -126,7 +126,10 @@ suite('BackupFileService', () => {
service
=
new
TestBackupFileService
(
workspaceResource
,
backupHome
,
workspacesJsonPath
);
service
.
hasBackup
(
fooFile
).
then
(
exists2
=>
{
assert
.
equal
(
exists2
,
true
);
done
();
return
service
.
hasBackups
().
then
(
hasBackups
=>
{
assert
.
ok
(
hasBackups
);
done
();
});
});
});
});
...
...
@@ -331,4 +334,4 @@ suite('BackupFilesModel', () => {
assert
.
deepEqual
(
model
.
get
().
map
(
f
=>
f
.
fsPath
),
[
file1
.
fsPath
,
file2
.
fsPath
,
untitled
.
fsPath
]);
});
});
\ No newline at end of file
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录