Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e72d8d15
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,发现更多精彩内容 >>
提交
e72d8d15
编写于
3月 28, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #46314: Make sure model change events reach the view models first
上级
4e7a6812
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
8 deletion
+57
-8
src/vs/editor/common/model.ts
src/vs/editor/common/model.ts
+7
-0
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+16
-6
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+1
-1
src/vs/editor/test/browser/controller/cursor.test.ts
src/vs/editor/test/browser/controller/cursor.test.ts
+33
-1
未找到文件。
src/vs/editor/common/model.ts
浏览文件 @
e72d8d15
...
@@ -1002,6 +1002,13 @@ export interface ITextModel {
...
@@ -1002,6 +1002,13 @@ export interface ITextModel {
*/
*/
redo
():
Selection
[];
redo
():
Selection
[];
/**
* @deprecated Please use `onDidChangeContent` instead.
* An event emitted when the contents of the model have changed.
* @internal
* @event
*/
onDidChangeRawContentFast
(
listener
:
(
e
:
ModelRawContentChangedEvent
)
=>
void
):
IDisposable
;
/**
/**
* @deprecated Please use `onDidChangeContent` instead.
* @deprecated Please use `onDidChangeContent` instead.
* An event emitted when the contents of the model have changed.
* An event emitted when the contents of the model have changed.
...
...
src/vs/editor/common/model/textModel.ts
浏览文件 @
e72d8d15
...
@@ -211,11 +211,14 @@ export class TextModel extends Disposable implements model.ITextModel {
...
@@ -211,11 +211,14 @@ export class TextModel extends Disposable implements model.ITextModel {
public
readonly
onDidChangeOptions
:
Event
<
IModelOptionsChangedEvent
>
=
this
.
_onDidChangeOptions
.
event
;
public
readonly
onDidChangeOptions
:
Event
<
IModelOptionsChangedEvent
>
=
this
.
_onDidChangeOptions
.
event
;
private
readonly
_eventEmitter
:
DidChangeContentEmitter
=
this
.
_register
(
new
DidChangeContentEmitter
());
private
readonly
_eventEmitter
:
DidChangeContentEmitter
=
this
.
_register
(
new
DidChangeContentEmitter
());
public
onDidChangeRawContentFast
(
listener
:
(
e
:
ModelRawContentChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
_eventEmitter
.
fastEvent
((
e
:
InternalModelContentChangeEvent
)
=>
listener
(
e
.
rawContentChangedEvent
));
}
public
onDidChangeRawContent
(
listener
:
(
e
:
ModelRawContentChangedEvent
)
=>
void
):
IDisposable
{
public
onDidChangeRawContent
(
listener
:
(
e
:
ModelRawContentChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
_eventEmitter
.
e
vent
((
e
:
InternalModelContentChangeEvent
)
=>
listener
(
e
.
rawContentChangedEvent
));
return
this
.
_eventEmitter
.
slowE
vent
((
e
:
InternalModelContentChangeEvent
)
=>
listener
(
e
.
rawContentChangedEvent
));
}
}
public
onDidChangeContent
(
listener
:
(
e
:
IModelContentChangedEvent
)
=>
void
):
IDisposable
{
public
onDidChangeContent
(
listener
:
(
e
:
IModelContentChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
_eventEmitter
.
e
vent
((
e
:
InternalModelContentChangeEvent
)
=>
listener
(
e
.
contentChangedEvent
));
return
this
.
_eventEmitter
.
slowE
vent
((
e
:
InternalModelContentChangeEvent
)
=>
listener
(
e
.
contentChangedEvent
));
}
}
//#endregion
//#endregion
...
@@ -2600,8 +2603,13 @@ export class DidChangeDecorationsEmitter extends Disposable {
...
@@ -2600,8 +2603,13 @@ export class DidChangeDecorationsEmitter extends Disposable {
export
class
DidChangeContentEmitter
extends
Disposable
{
export
class
DidChangeContentEmitter
extends
Disposable
{
private
readonly
_actual
:
Emitter
<
InternalModelContentChangeEvent
>
=
this
.
_register
(
new
Emitter
<
InternalModelContentChangeEvent
>
());
/**
public
readonly
event
:
Event
<
InternalModelContentChangeEvent
>
=
this
.
_actual
.
event
;
* Both `fastEvent` and `slowEvent` work the same way and contain the same events, but first we invoke `fastEvent` and then `slowEvent`.
*/
private
readonly
_fastEmitter
:
Emitter
<
InternalModelContentChangeEvent
>
=
this
.
_register
(
new
Emitter
<
InternalModelContentChangeEvent
>
());
public
readonly
fastEvent
:
Event
<
InternalModelContentChangeEvent
>
=
this
.
_fastEmitter
.
event
;
private
readonly
_slowEmitter
:
Emitter
<
InternalModelContentChangeEvent
>
=
this
.
_register
(
new
Emitter
<
InternalModelContentChangeEvent
>
());
public
readonly
slowEvent
:
Event
<
InternalModelContentChangeEvent
>
=
this
.
_slowEmitter
.
event
;
private
_deferredCnt
:
number
;
private
_deferredCnt
:
number
;
private
_deferredEvent
:
InternalModelContentChangeEvent
;
private
_deferredEvent
:
InternalModelContentChangeEvent
;
...
@@ -2622,7 +2630,8 @@ export class DidChangeContentEmitter extends Disposable {
...
@@ -2622,7 +2630,8 @@ export class DidChangeContentEmitter extends Disposable {
if
(
this
.
_deferredEvent
!==
null
)
{
if
(
this
.
_deferredEvent
!==
null
)
{
const
e
=
this
.
_deferredEvent
;
const
e
=
this
.
_deferredEvent
;
this
.
_deferredEvent
=
null
;
this
.
_deferredEvent
=
null
;
this
.
_actual
.
fire
(
e
);
this
.
_fastEmitter
.
fire
(
e
);
this
.
_slowEmitter
.
fire
(
e
);
}
}
}
}
}
}
...
@@ -2636,6 +2645,7 @@ export class DidChangeContentEmitter extends Disposable {
...
@@ -2636,6 +2645,7 @@ export class DidChangeContentEmitter extends Disposable {
}
}
return
;
return
;
}
}
this
.
_actual
.
fire
(
e
);
this
.
_fastEmitter
.
fire
(
e
);
this
.
_slowEmitter
.
fire
(
e
);
}
}
}
}
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
e72d8d15
...
@@ -173,7 +173,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -173,7 +173,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
private
_registerModelEvents
():
void
{
private
_registerModelEvents
():
void
{
this
.
_register
(
this
.
model
.
onDidChangeRawContent
((
e
)
=>
{
this
.
_register
(
this
.
model
.
onDidChangeRawContent
Fast
((
e
)
=>
{
try
{
try
{
const
eventsCollector
=
this
.
_beginEmit
();
const
eventsCollector
=
this
.
_beginEmit
();
...
...
src/vs/editor/test/browser/controller/cursor.test.ts
浏览文件 @
e72d8d15
...
@@ -17,11 +17,14 @@ import { IndentAction, IndentationRule } from 'vs/editor/common/modes/languageCo
...
@@ -17,11 +17,14 @@ import { IndentAction, IndentationRule } from 'vs/editor/common/modes/languageCo
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
TestConfiguration
}
from
'
vs/editor/test/common/mocks/testConfiguration
'
;
import
{
TestConfiguration
}
from
'
vs/editor/test/common/mocks/testConfiguration
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageIdentifier
,
ITokenizationSupport
,
IState
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CoreNavigationCommands
,
CoreEditingCommands
}
from
'
vs/editor/browser/controller/coreCommands
'
;
import
{
CoreNavigationCommands
,
CoreEditingCommands
}
from
'
vs/editor/browser/controller/coreCommands
'
;
import
{
withTestCodeEditor
}
from
'
vs/editor/test/browser/testCodeEditor
'
;
import
{
withTestCodeEditor
}
from
'
vs/editor/test/browser/testCodeEditor
'
;
import
{
ViewModel
}
from
'
vs/editor/common/viewModel/viewModelImpl
'
;
import
{
ViewModel
}
from
'
vs/editor/common/viewModel/viewModelImpl
'
;
import
{
NULL_STATE
}
from
'
vs/editor/common/modes/nullMode
'
;
import
{
TokenizationResult2
}
from
'
vs/editor/common/core/token
'
;
let
H
=
Handler
;
let
H
=
Handler
;
// --------- utils
// --------- utils
...
@@ -2048,6 +2051,35 @@ suite('Editor Controller - Regression tests', () => {
...
@@ -2048,6 +2051,35 @@ suite('Editor Controller - Regression tests', () => {
model
.
dispose
();
model
.
dispose
();
});
});
test
(
'
issue #46314: ViewModel is out of sync with Model!
'
,
()
=>
{
const
tokenizationSupport
:
ITokenizationSupport
=
{
getInitialState
:
()
=>
NULL_STATE
,
tokenize
:
undefined
,
tokenize2
:
(
line
:
string
,
state
:
IState
):
TokenizationResult2
=>
{
return
new
TokenizationResult2
(
null
,
state
);
}
};
const
LANGUAGE_ID
=
'
modelModeTest1
'
;
const
languageRegistration
=
TokenizationRegistry
.
register
(
LANGUAGE_ID
,
tokenizationSupport
);
let
model
=
TextModel
.
createFromString
(
'
Just text
'
,
undefined
,
new
LanguageIdentifier
(
LANGUAGE_ID
,
0
));
withTestCodeEditor
(
null
,
{
model
:
model
},
(
editor1
,
cursor1
)
=>
{
withTestCodeEditor
(
null
,
{
model
:
model
},
(
editor2
,
cursor2
)
=>
{
editor1
.
onDidChangeCursorPosition
(()
=>
{
model
.
tokenizeIfCheap
(
1
);
});
model
.
applyEdits
([{
range
:
new
Range
(
1
,
1
,
1
,
1
),
text
:
'
-
'
}]);
});
});
languageRegistration
.
dispose
();
model
.
dispose
();
});
});
});
suite
(
'
Editor Controller - Cursor Configuration
'
,
()
=>
{
suite
(
'
Editor Controller - Cursor Configuration
'
,
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录