Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2ded2a75
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,发现更多精彩内容 >>
提交
2ded2a75
编写于
9月 21, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Discard backups when the file is no longer dirty
Make content update trigger after dirty status is evaluated
上级
038f7564
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
17 deletion
+38
-17
src/vs/platform/files/common/files.ts
src/vs/platform/files/common/files.ts
+5
-0
src/vs/workbench/common/editor/untitledEditorModel.ts
src/vs/workbench/common/editor/untitledEditorModel.ts
+2
-2
src/vs/workbench/parts/files/common/editors/textFileEditorModel.ts
...rkbench/parts/files/common/editors/textFileEditorModel.ts
+4
-2
src/vs/workbench/parts/files/electron-browser/dirtyFilesTracker.ts
...rkbench/parts/files/electron-browser/dirtyFilesTracker.ts
+13
-10
src/vs/workbench/services/files/electron-browser/fileService.ts
.../workbench/services/files/electron-browser/fileService.ts
+4
-0
src/vs/workbench/services/files/node/fileService.ts
src/vs/workbench/services/files/node/fileService.ts
+10
-3
未找到文件。
src/vs/platform/files/common/files.ts
浏览文件 @
2ded2a75
...
...
@@ -110,6 +110,11 @@ export interface IFileService {
*/
backupFile
(
resource
:
URI
,
content
:
string
):
TPromise
<
IFileStat
>
;
/**
* Discard the backup for the resource specified.
*/
discardBackup
(
resource
:
URI
):
TPromise
<
void
>
;
/**
* Discards all backups associated with this session.
*/
...
...
src/vs/workbench/common/editor/untitledEditorModel.ts
浏览文件 @
2ded2a75
...
...
@@ -145,8 +145,6 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
}
private
onModelContentChanged
():
void
{
this
.
_onDidChangeContent
.
fire
();
// turn dirty if we were not
if
(
!
this
.
dirty
)
{
this
.
dirty
=
true
;
...
...
@@ -159,6 +157,8 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
this
.
dirty
=
false
;
this
.
_onDidChangeDirty
.
fire
();
}
this
.
_onDidChangeContent
.
fire
();
}
public
dispose
():
void
{
...
...
src/vs/workbench/parts/files/common/editors/textFileEditorModel.ts
浏览文件 @
2ded2a75
...
...
@@ -306,8 +306,6 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return
;
}
this
.
_onDidContentChange
.
fire
(
void
0
);
// The contents changed as a matter of Undo and the version reached matches the saved one
// In this case we clear the dirty flag and emit a SAVED event to indicate this state.
// Note: we currently only do this check when auto-save is turned off because there you see
...
...
@@ -324,6 +322,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
this
.
_onDidStateChange
.
fire
(
StateChange
.
REVERTED
);
}
this
.
_onDidContentChange
.
fire
(
void
0
);
return
;
}
...
...
@@ -340,6 +340,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
diag
(
'
makeDirty() - prevented save because we are in conflict resolution mode
'
,
this
.
resource
,
new
Date
());
}
}
this
.
_onDidContentChange
.
fire
(
void
0
);
}
private
makeDirty
():
void
{
...
...
src/vs/workbench/parts/files/electron-browser/dirtyFilesTracker.ts
浏览文件 @
2ded2a75
...
...
@@ -76,8 +76,13 @@ export class DirtyFilesTracker implements IWorkbenchContribution {
// TODO: Delay/throttle
let
untitledEditorInput
=
this
.
untitledEditorService
.
get
(
resource
);
untitledEditorInput
.
resolve
().
then
((
model
)
=>
{
// TODO: Deal with encoding?
this
.
fileService
.
backupFile
(
resource
,
model
.
getValue
());
if
(
model
.
isDirty
())
{
// TODO: Deal with encoding?
this
.
fileService
.
backupFile
(
resource
,
model
.
getValue
());
}
else
{
console
.
log
(
'
discard
'
);
this
.
fileService
.
discardBackup
(
resource
);
}
});
}
}
...
...
@@ -100,12 +105,16 @@ export class DirtyFilesTracker implements IWorkbenchContribution {
if
(
this
.
textFileService
.
isHotExitEnabled
())
{
let
model
=
this
.
textFileService
.
models
.
get
(
resource
);
this
.
fileService
.
backupFile
(
resource
,
model
.
getValue
());
if
(
model
.
isDirty
())
{
this
.
fileService
.
backupFile
(
resource
,
model
.
getValue
());
}
else
{
console
.
log
(
'
discard
'
);
this
.
fileService
.
discardBackup
(
resource
);
}
}
}
private
onTextFileDirty
(
e
:
TextFileModelChangeEvent
):
void
{
console
.
log
(
'
onTextFileDirty
'
,
e
);
if
((
this
.
textFileService
.
getAutoSaveMode
()
!==
AutoSaveMode
.
AFTER_SHORT_DELAY
)
&&
!
this
.
isDocumentedEdited
)
{
this
.
updateDocumentEdited
();
// no indication needed when auto save is enabled for short delay
...
...
@@ -123,12 +132,6 @@ export class DirtyFilesTracker implements IWorkbenchContribution {
if
(
!
this
.
pendingDirtyHandle
)
{
this
.
pendingDirtyHandle
=
setTimeout
(()
=>
this
.
doOpenDirtyResources
(),
250
);
}
if
(
this
.
textFileService
.
isHotExitEnabled
())
{
console
.
log
(
'
trigger hot exit
'
);
// TODO: Delay/throttle
this
.
textFileService
.
backup
(
e
.
resource
);
}
}
private
doOpenDirtyResources
():
void
{
...
...
src/vs/workbench/services/files/electron-browser/fileService.ts
浏览文件 @
2ded2a75
...
...
@@ -236,6 +236,10 @@ export class FileService implements IFileService {
return
this
.
raw
.
backupFile
(
resource
,
content
);
}
public
discardBackup
(
resource
:
uri
):
TPromise
<
void
>
{
return
this
.
raw
.
discardBackup
(
resource
);
}
public
discardBackups
():
TPromise
<
void
>
{
return
this
.
raw
.
discardBackups
();
}
...
...
src/vs/workbench/services/files/node/fileService.ts
浏览文件 @
2ded2a75
...
...
@@ -437,14 +437,21 @@ export class FileService implements IFileService {
public
backupFile
(
resource
:
uri
,
content
:
string
):
TPromise
<
IFileStat
>
{
// TODO: Implement properly
var
backupName
=
paths
.
basename
(
resource
.
fsPath
);
var
backupPath
=
paths
.
join
(
this
.
environmentService
.
userDataPath
,
'
File Backups
'
,
FileService
.
SESSION_BACKUP_ID
,
backupName
);
const
backupName
=
paths
.
basename
(
resource
.
fsPath
);
const
backupPath
=
paths
.
join
(
this
.
environmentService
.
userDataPath
,
'
File Backups
'
,
FileService
.
SESSION_BACKUP_ID
,
backupName
);
const
backupResource
=
uri
.
file
(
backupPath
);
let
backupResource
=
uri
.
file
(
backupPath
);
console
.
log
(
`Backing up to
${
backupResource
.
fsPath
}
`
);
return
this
.
updateContent
(
backupResource
,
content
);
}
public
discardBackup
(
resource
:
uri
):
TPromise
<
void
>
{
const
backupName
=
paths
.
basename
(
resource
.
fsPath
);
const
backupPath
=
paths
.
join
(
this
.
environmentService
.
userDataPath
,
'
File Backups
'
,
FileService
.
SESSION_BACKUP_ID
,
backupName
);
const
backupResource
=
uri
.
file
(
backupPath
);
return
this
.
del
(
backupResource
);
}
public
discardBackups
():
TPromise
<
void
>
{
return
this
.
del
(
uri
.
file
(
paths
.
join
(
this
.
environmentService
.
userDataPath
,
'
File Backups
'
,
FileService
.
SESSION_BACKUP_ID
)));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录