Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
13e394ff
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,发现更多精彩内容 >>
提交
13e394ff
编写于
3月 05, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null fixes for tests
上级
39e7e1f3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
20 deletion
+22
-20
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+3
-3
src/vs/workbench/common/editor/untitledEditorInput.ts
src/vs/workbench/common/editor/untitledEditorInput.ts
+3
-2
src/vs/workbench/common/editor/untitledEditorModel.ts
src/vs/workbench/common/editor/untitledEditorModel.ts
+3
-2
src/vs/workbench/test/common/editor/untitledEditor.test.ts
src/vs/workbench/test/common/editor/untitledEditor.test.ts
+9
-9
src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts
...bench/test/electron-browser/api/mainThreadEditors.test.ts
+4
-4
未找到文件。
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
13e394ff
...
...
@@ -860,9 +860,9 @@ export interface WorkspaceSymbolsDto extends IdObject {
}
export
interface
ResourceFileEditDto
{
oldUri
:
UriComponents
;
newUri
:
UriComponents
;
options
:
IFileOperationOptions
;
oldUri
?
:
UriComponents
;
newUri
?
:
UriComponents
;
options
?
:
IFileOperationOptions
;
}
export
interface
ResourceTextEditDto
{
...
...
src/vs/workbench/common/editor/untitledEditorInput.ts
浏览文件 @
13e394ff
...
...
@@ -17,6 +17,7 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
import
{
telemetryURIDescriptor
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
IResolvedTextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
/**
* An editor input to be used for untitled text buffers.
...
...
@@ -27,7 +28,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
private
_hasAssociatedFilePath
:
boolean
;
private
cachedModel
:
UntitledEditorModel
;
private
modelResolve
?:
Promise
<
UntitledEditorModel
>
;
private
modelResolve
?:
Promise
<
UntitledEditorModel
&
IResolvedTextEditorModel
>
;
private
readonly
_onDidModelChangeContent
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
get
onDidModelChangeContent
():
Event
<
void
>
{
return
this
.
_onDidModelChangeContent
.
event
;
}
...
...
@@ -199,7 +200,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
}
}
resolve
():
Promise
<
UntitledEditorModel
>
{
resolve
():
Promise
<
UntitledEditorModel
&
IResolvedTextEditorModel
>
{
// Join a model resolve if we have had one before
if
(
this
.
modelResolve
)
{
...
...
src/vs/workbench/common/editor/untitledEditorModel.ts
浏览文件 @
13e394ff
...
...
@@ -16,6 +16,7 @@ import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/resourceConfiguration
'
;
import
{
ITextBufferFactory
}
from
'
vs/editor/common/model
'
;
import
{
createTextBufferFactory
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IResolvedTextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
export
class
UntitledEditorModel
extends
BaseTextEditorModel
implements
IEncodingSupport
{
...
...
@@ -136,7 +137,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
this
.
contentChangeEventScheduler
.
schedule
();
}
load
():
Promise
<
UntitledEditorModel
>
{
load
():
Promise
<
UntitledEditorModel
&
IResolvedTextEditorModel
>
{
// Check for backups first
return
this
.
backupFileService
.
loadBackupResource
(
this
.
resource
).
then
((
backupResource
)
=>
{
...
...
@@ -180,7 +181,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
// Listen to mode changes
this
.
_register
(
textEditorModel
.
onDidChangeLanguage
(()
=>
this
.
onConfigurationChange
()));
// mode change can have impact on config
return
this
;
return
this
as
UntitledEditorModel
&
IResolvedTextEditorModel
;
});
}
...
...
src/vs/workbench/test/common/editor/untitledEditor.test.ts
浏览文件 @
13e394ff
...
...
@@ -68,7 +68,7 @@ suite('Workbench untitled editors', () => {
assert
.
equal
(
service
.
getAll
().
length
,
1
);
// dirty
input2
.
resolve
().
then
(
(
model
:
UntitledEditorModel
)
=>
{
input2
.
resolve
().
then
(
model
=>
{
assert
.
ok
(
!
service
.
isDirty
(
input2
.
getResource
()));
const
listener
=
service
.
onDidChangeDirty
(
resource
=>
{
...
...
@@ -112,7 +112,7 @@ suite('Workbench untitled editors', () => {
const
input
=
service
.
createOrGet
();
// dirty
return
input
.
resolve
().
then
(
(
model
:
UntitledEditorModel
)
=>
{
return
input
.
resolve
().
then
(
model
=>
{
model
.
textEditorModel
.
setValue
(
'
foo bar
'
);
assert
.
ok
(
model
.
isDirty
());
...
...
@@ -126,14 +126,14 @@ suite('Workbench untitled editors', () => {
test
(
'
Untitled via loadOrCreate
'
,
function
()
{
const
service
=
accessor
.
untitledEditorService
;
service
.
loadOrCreate
().
then
(
model1
=>
{
model1
.
textEditorModel
.
setValue
(
'
foo bar
'
);
model1
.
textEditorModel
!
.
setValue
(
'
foo bar
'
);
assert
.
ok
(
model1
.
isDirty
());
model1
.
textEditorModel
.
setValue
(
''
);
model1
.
textEditorModel
!
.
setValue
(
''
);
assert
.
ok
(
!
model1
.
isDirty
());
return
service
.
loadOrCreate
({
initialValue
:
'
Hello World
'
}).
then
(
model2
=>
{
assert
.
equal
(
snapshotToString
(
model2
.
createSnapshot
()),
'
Hello World
'
);
assert
.
equal
(
snapshotToString
(
model2
.
createSnapshot
()
!
),
'
Hello World
'
);
const
input
=
service
.
createOrGet
();
...
...
@@ -169,7 +169,7 @@ suite('Workbench untitled editors', () => {
const
input
=
service
.
createOrGet
(
file
);
// dirty
return
input
.
resolve
().
then
(
(
model
:
UntitledEditorModel
)
=>
{
return
input
.
resolve
().
then
(
model
=>
{
model
.
textEditorModel
.
setValue
(
'
foo bar
'
);
assert
.
ok
(
model
.
isDirty
());
...
...
@@ -223,7 +223,7 @@ suite('Workbench untitled editors', () => {
});
// dirty
return
input
.
resolve
().
then
(
(
model
:
UntitledEditorModel
)
=>
{
return
input
.
resolve
().
then
(
model
=>
{
model
.
setEncoding
(
'
utf16
'
);
assert
.
equal
(
counter
,
1
);
...
...
@@ -245,7 +245,7 @@ suite('Workbench untitled editors', () => {
assert
.
equal
(
r
.
toString
(),
input
.
getResource
().
toString
());
});
return
input
.
resolve
().
then
(
(
model
:
UntitledEditorModel
)
=>
{
return
input
.
resolve
().
then
(
model
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
equal
(
counter
,
0
,
'
Dirty model should not trigger event immediately
'
);
...
...
@@ -288,7 +288,7 @@ suite('Workbench untitled editors', () => {
assert
.
equal
(
r
.
toString
(),
input
.
getResource
().
toString
());
});
return
input
.
resolve
().
then
(
(
model
:
UntitledEditorModel
)
=>
{
return
input
.
resolve
().
then
(
model
=>
{
assert
.
equal
(
counter
,
0
);
input
.
dispose
();
assert
.
equal
(
counter
,
1
);
...
...
src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts
浏览文件 @
13e394ff
...
...
@@ -23,7 +23,7 @@ import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnviro
import
{
ResourceTextEdit
}
from
'
vs/editor/common/modes
'
;
import
{
BulkEditService
}
from
'
vs/workbench/services/bulkEdit/browser/bulkEditService
'
;
import
{
NullLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ITextModelService
,
ITextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ITextModelService
,
I
Resolved
TextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IReference
,
ImmortalReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
LabelService
}
from
'
vs/workbench/services/label/common/labelService
'
;
...
...
@@ -73,9 +73,9 @@ suite('MainThreadEditors', () => {
const
workbenchEditorService
=
new
TestEditorService
();
const
editorGroupService
=
new
TestEditorGroupsService
();
const
textModelService
=
new
class
extends
mock
<
ITextModelService
>
()
{
createModelReference
(
resource
:
URI
):
Promise
<
IReference
<
ITextEditorModel
>>
{
const
textEditorModel
:
ITextEditorModel
=
new
class
extends
mock
<
I
TextEditorModel
>
()
{
textEditorModel
=
modelService
.
getModel
(
resource
);
createModelReference
(
resource
:
URI
):
Promise
<
IReference
<
I
Resolved
TextEditorModel
>>
{
const
textEditorModel
=
new
class
extends
mock
<
IResolved
TextEditorModel
>
()
{
textEditorModel
=
modelService
.
getModel
(
resource
)
!
;
};
textEditorModel
.
isReadonly
=
()
=>
false
;
return
Promise
.
resolve
(
new
ImmortalReference
(
textEditorModel
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录