Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
e9b07aeb
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e9b07aeb
编写于
11月 14, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Evaluate if an untitled backup exists in UntitledEditorInput
上级
7f076284
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
18 addition
and
23 deletion
+18
-23
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+1
-1
src/vs/workbench/common/editor/untitledEditorInput.ts
src/vs/workbench/common/editor/untitledEditorInput.ts
+10
-15
src/vs/workbench/services/backup/common/backup.ts
src/vs/workbench/services/backup/common/backup.ts
+1
-1
src/vs/workbench/services/backup/node/backupFileService.ts
src/vs/workbench/services/backup/node/backupFileService.ts
+2
-2
src/vs/workbench/services/backup/test/backupFileService.test.ts
.../workbench/services/backup/test/backupFileService.test.ts
+2
-2
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+1
-1
src/vs/workbench/services/untitled/common/untitledEditorService.ts
...rkbench/services/untitled/common/untitledEditorService.ts
+1
-1
未找到文件。
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
e9b07aeb
...
@@ -665,7 +665,7 @@ export class TestBackupFileService implements IBackupFileService {
...
@@ -665,7 +665,7 @@ export class TestBackupFileService implements IBackupFileService {
return
[];
return
[];
}
}
public
has
TextFile
Backup
(
resource
:
URI
):
TPromise
<
boolean
>
{
public
hasBackup
(
resource
:
URI
):
TPromise
<
boolean
>
{
return
TPromise
.
as
(
false
);
return
TPromise
.
as
(
false
);
}
}
...
...
src/vs/workbench/common/editor/untitledEditorInput.ts
浏览文件 @
e9b07aeb
...
@@ -30,7 +30,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
...
@@ -30,7 +30,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
private
resource
:
URI
;
private
resource
:
URI
;
private
hasAssociatedFilePath
:
boolean
;
private
hasAssociatedFilePath
:
boolean
;
private
hasBackupToRestore
:
boolean
;
private
modeId
:
string
;
private
modeId
:
string
;
private
cachedModel
:
UntitledEditorModel
;
private
cachedModel
:
UntitledEditorModel
;
...
@@ -43,7 +42,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
...
@@ -43,7 +42,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
resource
:
URI
,
resource
:
URI
,
hasAssociatedFilePath
:
boolean
,
hasAssociatedFilePath
:
boolean
,
modeId
:
string
,
modeId
:
string
,
hasBackupToRestore
:
boolean
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IModeService
private
modeService
:
IModeService
,
@
IModeService
private
modeService
:
IModeService
,
...
@@ -54,7 +52,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
...
@@ -54,7 +52,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
this
.
resource
=
resource
;
this
.
resource
=
resource
;
this
.
hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
modeId
=
modeId
;
this
.
modeId
=
modeId
;
this
.
hasBackupToRestore
=
hasBackupToRestore
;
this
.
toUnbind
=
[];
this
.
toUnbind
=
[];
this
.
_onDidModelChangeContent
=
new
Emitter
<
void
>
();
this
.
_onDidModelChangeContent
=
new
Emitter
<
void
>
();
this
.
_onDidModelChangeEncoding
=
new
Emitter
<
void
>
();
this
.
_onDidModelChangeEncoding
=
new
Emitter
<
void
>
();
...
@@ -154,19 +151,17 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
...
@@ -154,19 +151,17 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
}
}
// Otherwise Create Model and load, restoring from backup if necessary
// Otherwise Create Model and load, restoring from backup if necessary
let
restorePromise
:
TPromise
<
string
>
;
return
this
.
backupFileService
.
hasBackup
(
this
.
resource
).
then
(
hasBackup
=>
{
if
(
this
.
hasBackupToRestore
)
{
if
(
hasBackup
)
{
// TODO: Pass in only Untitled-x into the constructor, evaluate whether there is a backup here.
// If the resource restored from backup it doesn't have an associated file path
const
restoreResource
=
this
.
backupFileService
.
getBackupResource
(
this
.
resource
);
this
.
hasAssociatedFilePath
=
false
;
restorePromise
=
this
.
textFileService
.
resolveTextContent
(
restoreResource
).
then
(
rawTextContent
=>
rawTextContent
.
value
.
lines
.
join
(
'
\n
'
));
const
restoreResource
=
this
.
backupFileService
.
getBackupResource
(
this
.
resource
);
// If the resource restored from backup it doesn't have an associated file path
return
this
.
textFileService
.
resolveTextContent
(
restoreResource
).
then
(
rawTextContent
=>
rawTextContent
.
value
.
lines
.
join
(
'
\n
'
));
this
.
hasAssociatedFilePath
=
false
;
}
}
else
{
restorePromise
=
TPromise
.
as
(
''
);
}
return
restorePromise
.
then
(
content
=>
{
return
''
;
}).
then
(
content
=>
{
const
model
=
this
.
createModel
(
content
);
const
model
=
this
.
createModel
(
content
);
return
model
.
load
().
then
((
resolvedModel
:
UntitledEditorModel
)
=>
{
return
model
.
load
().
then
((
resolvedModel
:
UntitledEditorModel
)
=>
{
this
.
cachedModel
=
resolvedModel
;
this
.
cachedModel
=
resolvedModel
;
...
...
src/vs/workbench/services/backup/common/backup.ts
浏览文件 @
e9b07aeb
...
@@ -47,7 +47,7 @@ export interface IBackupFileService {
...
@@ -47,7 +47,7 @@ export interface IBackupFileService {
* @param resource The resource to check.
* @param resource The resource to check.
* @returns Whether the file has a backup.
* @returns Whether the file has a backup.
*/
*/
has
TextFile
Backup
(
resource
:
Uri
):
TPromise
<
boolean
>
;
hasBackup
(
resource
:
Uri
):
TPromise
<
boolean
>
;
/**
/**
* Gets the backup resource for a particular resource within the current workspace.
* Gets the backup resource for a particular resource within the current workspace.
...
...
src/vs/workbench/services/backup/node/backupFileService.ts
浏览文件 @
e9b07aeb
...
@@ -37,12 +37,12 @@ export class BackupFileService implements IBackupFileService {
...
@@ -37,12 +37,12 @@ export class BackupFileService implements IBackupFileService {
});
});
}
}
public
has
TextFile
Backup
(
resource
:
Uri
):
TPromise
<
boolean
>
{
public
hasBackup
(
resource
:
Uri
):
TPromise
<
boolean
>
{
const
backupResource
=
this
.
getBackupResource
(
resource
);
const
backupResource
=
this
.
getBackupResource
(
resource
);
if
(
!
backupResource
)
{
if
(
!
backupResource
)
{
return
TPromise
.
as
(
false
);
return
TPromise
.
as
(
false
);
}
}
return
pfs
.
exists
(
this
.
getBackupResource
(
resource
)
.
fsPath
);
return
pfs
.
exists
(
backupResource
.
fsPath
);
}
}
public
getBackupResource
(
resource
:
Uri
):
Uri
{
public
getBackupResource
(
resource
:
Uri
):
Uri
{
...
...
src/vs/workbench/services/backup/test/backupFileService.test.ts
浏览文件 @
e9b07aeb
...
@@ -79,11 +79,11 @@ suite('BackupFileService', () => {
...
@@ -79,11 +79,11 @@ suite('BackupFileService', () => {
});
});
test
(
'
doesTextFileHaveBackup should return whether a backup resource exists
'
,
done
=>
{
test
(
'
doesTextFileHaveBackup should return whether a backup resource exists
'
,
done
=>
{
service
.
has
TextFile
Backup
(
fooFile
).
then
(
exists
=>
{
service
.
hasBackup
(
fooFile
).
then
(
exists
=>
{
assert
.
equal
(
exists
,
false
);
assert
.
equal
(
exists
,
false
);
pfs
.
mkdirp
(
path
.
dirname
(
fooBackupPath
)).
then
(()
=>
{
pfs
.
mkdirp
(
path
.
dirname
(
fooBackupPath
)).
then
(()
=>
{
fs
.
writeFileSync
(
fooBackupPath
,
'
foo
'
);
fs
.
writeFileSync
(
fooBackupPath
,
'
foo
'
);
service
.
has
TextFile
Backup
(
fooFile
).
then
(
exists2
=>
{
service
.
hasBackup
(
fooFile
).
then
(
exists2
=>
{
assert
.
equal
(
exists2
,
true
);
assert
.
equal
(
exists2
,
true
);
done
();
done
();
});
});
...
...
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
e9b07aeb
...
@@ -266,7 +266,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
...
@@ -266,7 +266,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
else
{
else
{
diag
(
'
load() - created text editor model
'
,
this
.
resource
,
new
Date
());
diag
(
'
load() - created text editor model
'
,
this
.
resource
,
new
Date
());
return
this
.
backupFileService
.
has
TextFile
Backup
(
this
.
resource
).
then
(
backupExists
=>
{
return
this
.
backupFileService
.
hasBackup
(
this
.
resource
).
then
(
backupExists
=>
{
let
getContentPromise
:
TPromise
<
IRawText
>
;
let
getContentPromise
:
TPromise
<
IRawText
>
;
if
(
backupExists
)
{
if
(
backupExists
)
{
const
restoreResource
=
this
.
backupFileService
.
getBackupResource
(
this
.
resource
);
const
restoreResource
=
this
.
backupFileService
.
getBackupResource
(
this
.
resource
);
...
...
src/vs/workbench/services/untitled/common/untitledEditorService.ts
浏览文件 @
e9b07aeb
...
@@ -185,7 +185,7 @@ export class UntitledEditorService implements IUntitledEditorService {
...
@@ -185,7 +185,7 @@ export class UntitledEditorService implements IUntitledEditorService {
}
while
(
Object
.
keys
(
UntitledEditorService
.
CACHE
).
indexOf
(
resource
.
toString
())
>=
0
);
}
while
(
Object
.
keys
(
UntitledEditorService
.
CACHE
).
indexOf
(
resource
.
toString
())
>=
0
);
}
}
const
input
=
this
.
instantiationService
.
createInstance
(
UntitledEditorInput
,
resource
,
hasAssociatedFilePath
,
modeId
,
hasBackupToRestore
);
const
input
=
this
.
instantiationService
.
createInstance
(
UntitledEditorInput
,
resource
,
hasAssociatedFilePath
,
modeId
);
if
(
input
.
isDirty
())
{
if
(
input
.
isDirty
())
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
_onDidChangeDirty
.
fire
(
resource
);
this
.
_onDidChangeDirty
.
fire
(
resource
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录