Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ab9f0b74
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,发现更多精彩内容 >>
提交
ab9f0b74
编写于
11月 22, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hot exit - add version id getters to models
上级
1816ae96
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
14 deletion
+37
-14
src/vs/workbench/common/editor/untitledEditorInput.ts
src/vs/workbench/common/editor/untitledEditorInput.ts
+0
-8
src/vs/workbench/common/editor/untitledEditorModel.ts
src/vs/workbench/common/editor/untitledEditorModel.ts
+8
-0
src/vs/workbench/parts/backup/common/backupModelTracker.ts
src/vs/workbench/parts/backup/common/backupModelTracker.ts
+2
-2
src/vs/workbench/services/backup/test/backupFileService.test.ts
.../workbench/services/backup/test/backupFileService.test.ts
+18
-4
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+7
-0
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+2
-0
未找到文件。
src/vs/workbench/common/editor/untitledEditorInput.ts
浏览文件 @
ab9f0b74
...
...
@@ -133,14 +133,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
return
null
;
}
public
getValue
():
string
{
if
(
this
.
cachedModel
)
{
return
this
.
cachedModel
.
getValue
();
}
return
null
;
}
public
setEncoding
(
encoding
:
string
,
mode
:
EncodingMode
/* ignored, we only have Encode */
):
void
{
if
(
this
.
cachedModel
)
{
this
.
cachedModel
.
setEncoding
(
encoding
);
...
...
src/vs/workbench/common/editor/untitledEditorModel.ts
浏览文件 @
ab9f0b74
...
...
@@ -33,6 +33,8 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
private
_onDidChangeDirty
:
Emitter
<
void
>
;
private
_onDidChangeEncoding
:
Emitter
<
void
>
;
private
versionId
:
number
;
private
contentChangeEventScheduler
:
RunOnceScheduler
;
private
configuredEncoding
:
string
;
...
...
@@ -54,6 +56,7 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
this
.
hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
dirty
=
false
;
this
.
versionId
=
0
;
this
.
_onDidChangeContent
=
new
Emitter
<
void
>
();
this
.
_onDidChangeDirty
=
new
Emitter
<
void
>
();
...
...
@@ -94,6 +97,10 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
this
.
configuredEncoding
=
configuration
&&
configuration
.
files
&&
configuration
.
files
.
encoding
;
}
public
getVersionId
():
number
{
return
this
.
versionId
;
}
public
getValue
():
string
{
if
(
this
.
textEditorModel
)
{
return
this
.
textEditorModel
.
getValue
(
EndOfLinePreference
.
TextDefined
,
true
/* Preserve BOM */
);
...
...
@@ -179,6 +186,7 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
}
private
onModelContentChanged
():
void
{
this
.
versionId
++
;
// mark the untitled editor as non-dirty once its content becomes empty and we do
// not have an associated path set. we never want dirty indicator in that case.
...
...
src/vs/workbench/parts/backup/common/backupModelTracker.ts
浏览文件 @
ab9f0b74
...
...
@@ -65,9 +65,9 @@ export class BackupModelTracker implements IWorkbenchContribution {
if
(
this
.
backupService
.
isHotExitEnabled
)
{
const
input
=
this
.
untitledEditorService
.
get
(
resource
);
if
(
input
.
isDirty
())
{
this
.
backupFileService
.
backupResource
(
resource
,
input
.
getValue
(
));
input
.
resolve
().
then
(
model
=>
this
.
backupFileService
.
backupResource
(
resource
,
model
.
getValue
()
));
}
else
{
this
.
backupFileService
.
discardResource
Backup
(
resource
);
this
.
discard
Backup
(
resource
);
}
}
}
...
...
src/vs/workbench/services/backup/test/backupFileService.test.ts
浏览文件 @
ab9f0b74
...
...
@@ -14,17 +14,31 @@ import path = require('path');
import
extfs
=
require
(
'
vs/base/node/extfs
'
);
import
pfs
=
require
(
'
vs/base/node/pfs
'
);
import
Uri
from
'
vs/base/common/uri
'
;
import
{
TestEnvironmentService
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
BackupFileService
}
from
'
vs/workbench/services/backup/node/backupFileService
'
;
import
{
FileService
}
from
'
vs/workbench/services/files/node/fileService
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
parseArgs
}
from
'
vs/platform/environment/node/argv
'
;
class
TestEnvironmentService
extends
EnvironmentService
{
constructor
(
private
_backupHome
:
string
,
private
_backupWorkspacesPath
:
string
)
{
super
(
parseArgs
(
process
.
argv
),
process
.
execPath
);
this
.
_backupHome
=
this
.
_backupHome
||
this
.
backupHome
;
this
.
_backupWorkspacesPath
=
this
.
_backupWorkspacesPath
||
this
.
backupWorkspacesPath
;
}
get
backupHome
():
string
{
return
this
.
_backupHome
;
}
get
backupWorkspacesPath
():
string
{
return
this
.
_backupWorkspacesPath
;
}
}
class
TestBackupFileService
extends
BackupFileService
{
constructor
(
workspace
:
Uri
,
backupHome
:
string
,
workspacesJsonPath
:
string
)
{
const
fileService
=
new
FileService
(
workspace
.
fsPath
,
{
disableWatcher
:
true
},
null
);
super
(
workspace
,
TestEnvironmentService
,
fileService
);
const
testEnvironmentService
=
new
TestEnvironmentService
(
backupHome
,
workspacesJsonPath
);
this
.
backupHome
=
backupHome
;
this
.
workspacesJsonPath
=
workspacesJsonPath
;
super
(
workspace
,
testEnvironmentService
,
fileService
);
}
}
...
...
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
ab9f0b74
...
...
@@ -139,6 +139,13 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return
this
.
_onDidStateChange
.
event
;
}
/**
* The current version id of the model.
*/
public
getVersionId
():
number
{
return
this
.
versionId
;
}
/**
* Set a save error handler to install code that executes when save errors occur.
*/
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
ab9f0b74
...
...
@@ -209,6 +209,8 @@ export interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport
onDidContentChange
:
Event
<
StateChange
>
;
onDidStateChange
:
Event
<
StateChange
>
;
getVersionId
():
number
;
getResource
():
URI
;
getLastSaveAttemptTime
():
number
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录