Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5f545975
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 搜索 >>
提交
5f545975
编写于
3月 01, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tests
上级
deeafc26
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
22 deletion
+28
-22
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
...orkbench/parts/files/test/browser/fileEditorInput.test.ts
+6
-6
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+7
-7
src/vs/workbench/services/textfile/test/textFileEditorModel.test.ts
...kbench/services/textfile/test/textFileEditorModel.test.ts
+15
-9
未找到文件。
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
浏览文件 @
5f545975
...
...
@@ -58,7 +58,7 @@ suite('Files - FileEditorInput', () => {
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
toResource
.
call
(
this
,
'
/foo/bar.html
'
),
void
0
);
const
inputToResolve
:
any
=
instantiationService
.
createInstance
(
FileEditorInput
,
toResource
.
call
(
this
,
'
/foo/bar/file.js
'
),
void
0
);
const
inputToResolve
=
instantiationService
.
createInstance
(
FileEditorInput
,
toResource
.
call
(
this
,
'
/foo/bar/file.js
'
),
void
0
);
const
sameOtherInput
=
instantiationService
.
createInstance
(
FileEditorInput
,
toResource
.
call
(
this
,
'
/foo/bar/file.js
'
),
void
0
);
return
inputToResolve
.
resolve
(
true
).
then
(
resolved
=>
{
...
...
@@ -69,7 +69,7 @@ suite('Files - FileEditorInput', () => {
return
sameOtherInput
.
resolve
(
true
).
then
(
otherResolved
=>
{
assert
(
otherResolved
===
resolvedModelA
);
// OK: Resolved Model cached globally per input
inputToResolve
.
dispose
(
false
);
inputToResolve
.
dispose
();
return
inputToResolve
.
resolve
(
true
).
then
(
resolved
=>
{
assert
(
resolvedModelA
===
resolved
);
// Model is still the same because we had 2 clients
...
...
@@ -82,13 +82,13 @@ suite('Files - FileEditorInput', () => {
return
inputToResolve
.
resolve
(
true
).
then
(
resolved
=>
{
assert
(
resolvedModelA
!==
resolved
);
// Different instance, because input got disposed
let
stat
=
(
<
any
>
resolved
).
versionOnDiskStat
;
let
stat
=
resolved
.
getStat
()
;
return
inputToResolve
.
resolve
(
true
).
then
(
resolved
=>
{
assert
(
stat
!==
(
<
any
>
resolved
).
versionOnDiskStat
);
// Different stat, because resolve always goes to the server for refresh
assert
(
stat
!==
resolved
.
getStat
()
);
// Different stat, because resolve always goes to the server for refresh
stat
=
(
<
any
>
resolved
).
versionOnDiskStat
;
stat
=
resolved
.
getStat
()
;
return
inputToResolve
.
resolve
(
false
).
then
(
resolved
=>
{
assert
(
stat
===
(
<
any
>
resolved
).
versionOnDiskStat
);
// Same stat, because not refreshed
assert
(
stat
===
resolved
.
getStat
()
);
// Same stat, because not refreshed
done
();
});
...
...
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
5f545975
...
...
@@ -732,13 +732,6 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return
this
.
lastSaveAttemptTime
;
}
/**
* Returns the time in millies when this working copy was last modified by the user or some other program.
*/
public
getLastModifiedTime
():
number
{
return
this
.
lastResolvedDiskStat
?
this
.
lastResolvedDiskStat
.
mtime
:
-
1
;
}
/**
* Returns the time in millies when this working copy was last modified by the user or some other program.
*/
...
...
@@ -852,6 +845,13 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return
this
.
resource
;
}
/**
* Stat accessor only used by tests.
*/
public
getStat
():
IFileStat
{
return
this
.
lastResolvedDiskStat
;
}
public
dispose
():
void
{
this
.
disposed
=
true
;
this
.
inConflictResolutionMode
=
false
;
...
...
src/vs/workbench/services/textfile/test/textFileEditorModel.test.ts
浏览文件 @
5f545975
...
...
@@ -22,6 +22,12 @@ class ServiceAccessor {
}
}
function
getLastModifiedTime
(
model
:
TextFileEditorModel
):
number
{
const
stat
=
model
.
getStat
();
return
stat
?
stat
.
mtime
:
-
1
;
}
suite
(
'
Files - TextFileEditorModel
'
,
()
=>
{
let
instantiationService
:
IInstantiationService
;
...
...
@@ -42,7 +48,7 @@ suite('Files - TextFileEditorModel', () => {
model
.
load
().
done
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
bar
'
);
assert
.
ok
(
model
.
getLastModifiedTime
(
)
<=
Date
.
now
());
assert
.
ok
(
getLastModifiedTime
(
model
)
<=
Date
.
now
());
return
model
.
save
().
then
(()
=>
{
assert
.
ok
(
model
.
getLastSaveAttemptTime
()
<=
Date
.
now
());
...
...
@@ -60,11 +66,11 @@ suite('Files - TextFileEditorModel', () => {
const
model
:
TextFileEditorModel
=
instantiationService
.
createInstance
(
TextFileEditorModel
,
toResource
.
call
(
this
,
'
/path/index_async.txt
'
),
'
utf8
'
);
model
.
setEncoding
(
'
utf8
'
,
EncodingMode
.
Encode
);
// no-op
assert
.
equal
(
model
.
getLastModifiedTime
(
),
-
1
);
assert
.
equal
(
getLastModifiedTime
(
model
),
-
1
);
model
.
setEncoding
(
'
utf16
'
,
EncodingMode
.
Encode
);
assert
.
ok
(
model
.
getLastModifiedTime
(
)
<=
Date
.
now
());
// indicates model was saved due to encoding change
assert
.
ok
(
getLastModifiedTime
(
model
)
<=
Date
.
now
());
// indicates model was saved due to encoding change
model
.
dispose
();
});
...
...
@@ -188,7 +194,7 @@ suite('Files - TextFileEditorModel', () => {
const
model
:
TextFileEditorModel
=
instantiationService
.
createInstance
(
TextFileEditorModel
,
toResource
.
call
(
this
,
'
/path/index_async.txt
'
),
'
utf8
'
);
model
.
load
().
done
(()
=>
{
const
mtime
=
model
.
getLastModifiedTime
(
);
const
mtime
=
getLastModifiedTime
(
model
);
accessor
.
textFileService
.
setResolveTextContentErrorOnce
(
<
IFileOperationResult
>
{
message
:
'
error
'
,
fileOperationResult
:
FileOperationResult
.
FILE_NOT_MODIFIED_SINCE
...
...
@@ -196,7 +202,7 @@ suite('Files - TextFileEditorModel', () => {
return
model
.
load
().
then
((
model
:
TextFileEditorModel
)
=>
{
assert
.
ok
(
model
);
assert
.
equal
(
model
.
getLastModifiedTime
(
),
mtime
);
assert
.
equal
(
getLastModifiedTime
(
model
),
mtime
);
model
.
dispose
();
done
();
...
...
@@ -267,8 +273,8 @@ suite('Files - TextFileEditorModel', () => {
return
input2
.
resolve
().
then
((
model2
:
TextFileEditorModel
)
=>
{
model1
.
textEditorModel
.
setValue
(
'
foo
'
);
const
m1Mtime
=
model1
.
get
LastModifiedTime
()
;
const
m2Mtime
=
model2
.
get
LastModifiedTime
()
;
const
m1Mtime
=
model1
.
get
Stat
().
mtime
;
const
m2Mtime
=
model2
.
get
Stat
().
mtime
;
assert
.
ok
(
m1Mtime
>
0
);
assert
.
ok
(
m2Mtime
>
0
);
...
...
@@ -283,8 +289,8 @@ suite('Files - TextFileEditorModel', () => {
accessor
.
textFileService
.
saveAll
().
then
(()
=>
{
assert
.
ok
(
!
accessor
.
textFileService
.
isDirty
(
toResource
.
call
(
this
,
'
/path/index_async.txt
'
)));
assert
.
ok
(
!
accessor
.
textFileService
.
isDirty
(
toResource
.
call
(
this
,
'
/path/index_async2.txt
'
)));
assert
.
ok
(
model1
.
get
LastModifiedTime
()
>
m1Mtime
);
assert
.
ok
(
model2
.
get
LastModifiedTime
()
>
m2Mtime
);
assert
.
ok
(
model1
.
get
Stat
().
mtime
>
m1Mtime
);
assert
.
ok
(
model2
.
get
Stat
().
mtime
>
m2Mtime
);
assert
.
ok
(
model1
.
getLastSaveAttemptTime
()
>
m1Mtime
);
assert
.
ok
(
model2
.
getLastSaveAttemptTime
()
>
m2Mtime
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录