Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a8fe75f0
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,发现更多精彩内容 >>
未验证
提交
a8fe75f0
编写于
5月 25, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Emit cursor state change events through view model
上级
4ba9ad5d
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
194 addition
and
161 deletion
+194
-161
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+33
-31
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+24
-68
src/vs/editor/common/view/viewEvents.ts
src/vs/editor/common/view/viewEvents.ts
+0
-21
src/vs/editor/common/viewModel/viewModelEventDispatcher.ts
src/vs/editor/common/viewModel/viewModelEventDispatcher.ts
+96
-8
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+25
-25
src/vs/editor/test/browser/controller/cursor.test.ts
src/vs/editor/test/browser/controller/cursor.test.ts
+16
-8
未找到文件。
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
a8fe75f0
...
...
@@ -23,7 +23,7 @@ import { ICommandDelegate } from 'vs/editor/browser/view/viewController';
import
{
IContentWidgetData
,
IOverlayWidgetData
,
View
}
from
'
vs/editor/browser/view/viewImpl
'
;
import
{
ViewOutgoingEvents
}
from
'
vs/editor/browser/view/viewOutgoingEvents
'
;
import
{
ConfigurationChangedEvent
,
EditorLayoutInfo
,
IEditorOptions
,
EditorOption
,
IComputedEditorOptions
,
FindComputedEditorOptionValueById
,
IEditorConstructionOptions
,
filterValidationDecorations
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
Cursor
,
CursorStateChangedEvent
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
CursorColumns
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
ICursorPositionChangedEvent
,
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
IPosition
,
Position
}
from
'
vs/editor/common/core/position
'
;
...
...
@@ -1477,7 +1477,21 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
this
.
_onDidAttemptReadOnlyEdit
.
fire
(
undefined
);
}));
listenersToRemove
.
push
(
viewModel
.
cursor
.
onDidChange
((
e
:
CursorStateChangedEvent
)
=>
{
listenersToRemove
.
push
(
viewModel
.
onEvent
((
e
)
=>
{
switch
(
e
.
kind
)
{
case
OutgoingViewModelEventKind
.
ContentSizeChanged
:
this
.
_onDidContentSizeChange
.
fire
(
e
);
break
;
case
OutgoingViewModelEventKind
.
FocusChanged
:
this
.
_editorTextFocus
.
setValue
(
e
.
hasFocus
);
break
;
case
OutgoingViewModelEventKind
.
ScrollChanged
:
this
.
_onDidScrollChange
.
fire
(
e
);
break
;
case
OutgoingViewModelEventKind
.
ViewZonesChanged
:
this
.
_onDidChangeViewZones
.
fire
();
break
;
case
OutgoingViewModelEventKind
.
CursorStateChanged
:
{
if
(
e
.
reachedMaxCursorCount
)
{
this
.
_notificationService
.
warn
(
nls
.
localize
(
'
cursors.maximum
'
,
"
The number of cursors has been limited to {0}.
"
,
Cursor
.
MAX_CURSOR_COUNT
));
}
...
...
@@ -1505,23 +1519,11 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
reason
:
e
.
reason
};
this
.
_onDidChangeCursorSelection
.
fire
(
e2
);
}));
listenersToRemove
.
push
(
viewModel
.
onEvent
((
e
)
=>
{
switch
(
e
.
kind
)
{
case
OutgoingViewModelEventKind
.
ContentSizeChanged
:
this
.
_onDidContentSizeChange
.
fire
(
e
);
break
;
case
OutgoingViewModelEventKind
.
FocusChanged
:
this
.
_editorTextFocus
.
setValue
(
e
.
hasFocus
);
break
;
case
OutgoingViewModelEventKind
.
ScrollChanged
:
this
.
_onDidScrollChange
.
fire
(
e
);
break
;
case
OutgoingViewModelEventKind
.
ViewZonesChanged
:
this
.
_onDidChangeViewZones
.
fire
();
break
;
}
}
}));
const
[
view
,
hasRealView
]
=
this
.
_createView
(
viewModel
);
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
a8fe75f0
...
...
@@ -17,51 +17,10 @@ import { ISelection, Selection, SelectionDirection } from 'vs/editor/common/core
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextModel
,
TrackedRangeStickiness
,
IModelDeltaDecoration
,
ICursorStateComputer
,
IIdentifiedSingleEditOperation
,
IValidEditOperation
}
from
'
vs/editor/common/model
'
;
import
{
RawContentChangedType
,
ModelRawContentChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
V
iewEventsCollector
,
V
erticalRevealType
,
ViewCursorStateChangedEvent
,
ViewRevealRangeRequestEvent
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
VerticalRevealType
,
ViewCursorStateChangedEvent
,
ViewRevealRangeRequestEvent
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICoordinatesConverter
}
from
'
vs/editor/common/viewModel/viewModel
'
;
export
class
CursorStateChangedEvent
{
/**
* The new selections.
* The primary selection is always at index 0.
*/
readonly
selections
:
Selection
[];
/**
* The new model version id that `selections` apply to.
*/
readonly
modelVersionId
:
number
;
/**
* The old selections.
*/
readonly
oldSelections
:
Selection
[]
|
null
;
/**
* The model version id the that `oldSelections` apply to.
*/
readonly
oldModelVersionId
:
number
;
/**
* Source of the call that caused the event.
*/
readonly
source
:
string
;
/**
* Reason.
*/
readonly
reason
:
CursorChangeReason
;
/**
* The number of cursors was limited because it has reached the maximum cursor count.
*/
readonly
reachedMaxCursorCount
:
boolean
;
constructor
(
selections
:
Selection
[],
modelVersionId
:
number
,
oldSelections
:
Selection
[]
|
null
,
oldModelVersionId
:
number
,
source
:
string
,
reason
:
CursorChangeReason
,
reachedMaxCursorCount
:
boolean
)
{
this
.
selections
=
selections
;
this
.
modelVersionId
=
modelVersionId
;
this
.
oldSelections
=
oldSelections
;
this
.
oldModelVersionId
=
oldModelVersionId
;
this
.
source
=
source
;
this
.
reason
=
reason
;
this
.
reachedMaxCursorCount
=
reachedMaxCursorCount
;
}
}
import
{
CursorStateChangedEvent
,
ViewModelEventsCollector
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
/**
* A snapshot of the cursor and the model state
...
...
@@ -168,9 +127,6 @@ export class Cursor extends Disposable {
private
readonly
_onDidAttemptReadOnlyEdit
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidAttemptReadOnlyEdit
:
Event
<
void
>
=
this
.
_onDidAttemptReadOnlyEdit
.
event
;
private
readonly
_onDidChange
:
Emitter
<
CursorStateChangedEvent
>
=
this
.
_register
(
new
Emitter
<
CursorStateChangedEvent
>
());
public
readonly
onDidChange
:
Event
<
CursorStateChangedEvent
>
=
this
.
_onDidChange
.
event
;
private
readonly
_model
:
ITextModel
;
private
_knownModelVersionId
:
number
;
private
readonly
_viewModel
:
ICursorSimpleModel
;
...
...
@@ -215,7 +171,7 @@ export class Cursor extends Disposable {
this
.
_cursors
.
updateContext
(
this
.
context
);
}
public
onLineMappingChanged
(
eventsCollector
:
ViewEventsCollector
):
void
{
public
onLineMappingChanged
(
eventsCollector
:
View
Model
EventsCollector
):
void
{
if
(
this
.
_knownModelVersionId
!==
this
.
_model
.
getVersionId
())
{
// There are model change events that I didn't yet receive.
//
...
...
@@ -262,7 +218,7 @@ export class Cursor extends Disposable {
return
this
.
_cursors
.
getAll
();
}
public
setStates
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
states
:
PartialCursorState
[]
|
null
):
boolean
{
public
setStates
(
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
states
:
PartialCursorState
[]
|
null
):
boolean
{
let
reachedMaxCursorCount
=
false
;
if
(
states
!==
null
&&
states
.
length
>
Cursor
.
MAX_CURSOR_COUNT
)
{
states
=
states
.
slice
(
0
,
Cursor
.
MAX_CURSOR_COUNT
);
...
...
@@ -284,7 +240,7 @@ export class Cursor extends Disposable {
this
.
_columnSelectData
=
columnSelectData
;
}
public
revealPrimary
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
public
revealPrimary
(
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
const
viewPositions
=
this
.
_cursors
.
getViewPositions
();
if
(
viewPositions
.
length
>
1
)
{
this
.
_emitCursorRevealRange
(
eventsCollector
,
source
,
null
,
this
.
_cursors
.
getViewSelections
(),
VerticalRevealType
.
Simple
,
revealHorizontal
,
scrollType
);
...
...
@@ -296,7 +252,7 @@ export class Cursor extends Disposable {
}
}
private
_revealPrimaryCursor
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
private
_revealPrimaryCursor
(
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
const
viewPositions
=
this
.
_cursors
.
getViewPositions
();
if
(
viewPositions
.
length
>
1
)
{
this
.
_emitCursorRevealRange
(
eventsCollector
,
source
,
null
,
this
.
_cursors
.
getViewSelections
(),
verticalType
,
revealHorizontal
,
scrollType
);
...
...
@@ -307,8 +263,8 @@ export class Cursor extends Disposable {
}
}
private
_emitCursorRevealRange
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
viewRange
:
Range
|
null
,
viewSelections
:
Selection
[]
|
null
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
)
{
eventsCollector
.
emit
(
new
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
viewSelections
,
verticalType
,
revealHorizontal
,
scrollType
));
private
_emitCursorRevealRange
(
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
viewRange
:
Range
|
null
,
viewSelections
:
Selection
[]
|
null
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
)
{
eventsCollector
.
emit
ViewEvent
(
new
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
viewSelections
,
verticalType
,
revealHorizontal
,
scrollType
));
}
public
saveState
():
editorCommon
.
ICursorState
[]
{
...
...
@@ -335,7 +291,7 @@ export class Cursor extends Disposable {
return
result
;
}
public
restoreState
(
eventsCollector
:
ViewEventsCollector
,
states
:
editorCommon
.
ICursorState
[]):
void
{
public
restoreState
(
eventsCollector
:
View
Model
EventsCollector
,
states
:
editorCommon
.
ICursorState
[]):
void
{
let
desiredSelections
:
ISelection
[]
=
[];
...
...
@@ -376,7 +332,7 @@ export class Cursor extends Disposable {
this
.
revealPrimary
(
eventsCollector
,
'
restoreState
'
,
true
,
editorCommon
.
ScrollType
.
Immediate
);
}
public
onModelContentChanged
(
eventsCollector
:
ViewEventsCollector
,
e
:
ModelRawContentChangedEvent
):
void
{
public
onModelContentChanged
(
eventsCollector
:
View
Model
EventsCollector
,
e
:
ModelRawContentChangedEvent
):
void
{
this
.
_knownModelVersionId
=
e
.
versionId
;
if
(
this
.
_isHandling
)
{
...
...
@@ -441,7 +397,7 @@ export class Cursor extends Disposable {
return
this
.
_cursors
.
getPrimaryCursor
().
modelState
.
position
;
}
public
setSelections
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
selections
:
readonly
ISelection
[]):
void
{
public
setSelections
(
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
selections
:
readonly
ISelection
[]):
void
{
this
.
setStates
(
eventsCollector
,
source
,
CursorChangeReason
.
NotSet
,
CursorState
.
fromModelSelections
(
selections
));
}
...
...
@@ -533,7 +489,7 @@ export class Cursor extends Disposable {
// -----------------------------------------------------------------------------------------------------------
// ----- emitting events
private
_emitStateChangedIfNecessary
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
oldState
:
CursorModelState
|
null
,
reachedMaxCursorCount
:
boolean
):
boolean
{
private
_emitStateChangedIfNecessary
(
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
oldState
:
CursorModelState
|
null
,
reachedMaxCursorCount
:
boolean
):
boolean
{
const
newState
=
new
CursorModelState
(
this
.
_model
,
this
);
if
(
newState
.
equals
(
oldState
))
{
return
false
;
...
...
@@ -543,7 +499,7 @@ export class Cursor extends Disposable {
const
viewSelections
=
this
.
_cursors
.
getViewSelections
();
// Let the view get the event first.
eventsCollector
.
emit
(
new
ViewCursorStateChangedEvent
(
viewSelections
,
selections
));
eventsCollector
.
emit
ViewEvent
(
new
ViewCursorStateChangedEvent
(
viewSelections
,
selections
));
// Only after the view has been notified, let the rest of the world know...
if
(
!
oldState
...
...
@@ -552,7 +508,7 @@ export class Cursor extends Disposable {
)
{
const
oldSelections
=
oldState
?
oldState
.
cursorState
.
map
(
s
=>
s
.
modelState
.
selection
)
:
null
;
const
oldModelVersionId
=
oldState
?
oldState
.
modelVersionId
:
0
;
this
.
_onDidChange
.
fire
(
new
CursorStateChangedEvent
(
selections
,
newState
.
modelVersionId
,
oldSelections
,
oldM
odelVersionId
,
source
||
'
keyboard
'
,
reason
,
reachedMaxCursorCount
));
eventsCollector
.
emitOutgoingEvent
(
new
CursorStateChangedEvent
(
oldSelections
,
selections
,
oldModelVersionId
,
newState
.
m
odelVersionId
,
source
||
'
keyboard
'
,
reason
,
reachedMaxCursorCount
));
}
return
true
;
...
...
@@ -597,7 +553,7 @@ export class Cursor extends Disposable {
return
indices
;
}
public
executeEdits
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
edits
:
IIdentifiedSingleEditOperation
[],
cursorStateComputer
:
ICursorStateComputer
):
void
{
public
executeEdits
(
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
edits
:
IIdentifiedSingleEditOperation
[],
cursorStateComputer
:
ICursorStateComputer
):
void
{
let
autoClosingIndices
:
[
number
,
number
][]
|
null
=
null
;
if
(
source
===
'
snippet
'
)
{
autoClosingIndices
=
this
.
_findAutoClosingPairs
(
edits
);
...
...
@@ -639,7 +595,7 @@ export class Cursor extends Disposable {
}
}
private
_executeEdit
(
callback
:
()
=>
void
,
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
cursorChangeReason
:
CursorChangeReason
=
CursorChangeReason
.
NotSet
):
void
{
private
_executeEdit
(
callback
:
()
=>
void
,
eventsCollector
:
View
Model
EventsCollector
,
source
:
string
|
null
|
undefined
,
cursorChangeReason
:
CursorChangeReason
=
CursorChangeReason
.
NotSet
):
void
{
if
(
this
.
context
.
cursorConfig
.
readOnly
)
{
// we cannot edit when read only...
this
.
_onDidAttemptReadOnlyEdit
.
fire
(
undefined
);
...
...
@@ -665,12 +621,12 @@ export class Cursor extends Disposable {
}
}
public
startComposition
(
eventsCollector
:
ViewEventsCollector
):
void
{
public
startComposition
(
eventsCollector
:
View
Model
EventsCollector
):
void
{
this
.
_isDoingComposition
=
true
;
this
.
_selectionsWhenCompositionStarted
=
this
.
getSelections
().
slice
(
0
);
}
public
endComposition
(
eventsCollector
:
ViewEventsCollector
,
source
?:
string
|
null
|
undefined
):
void
{
public
endComposition
(
eventsCollector
:
View
Model
EventsCollector
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_isDoingComposition
=
false
;
this
.
_executeEdit
(()
=>
{
if
(
!
this
.
_isDoingComposition
&&
source
===
'
keyboard
'
)
{
...
...
@@ -682,7 +638,7 @@ export class Cursor extends Disposable {
},
eventsCollector
,
source
);
}
public
type
(
eventsCollector
:
ViewEventsCollector
,
text
:
string
,
source
?:
string
|
null
|
undefined
):
void
{
public
type
(
eventsCollector
:
View
Model
EventsCollector
,
text
:
string
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
if
(
source
===
'
keyboard
'
)
{
// If this event is coming straight from the keyboard, look for electric characters and enter
...
...
@@ -706,25 +662,25 @@ export class Cursor extends Disposable {
},
eventsCollector
,
source
);
}
public
replacePreviousChar
(
eventsCollector
:
ViewEventsCollector
,
text
:
string
,
replaceCharCnt
:
number
,
source
?:
string
|
null
|
undefined
):
void
{
public
replacePreviousChar
(
eventsCollector
:
View
Model
EventsCollector
,
text
:
string
,
replaceCharCnt
:
number
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
TypeOperations
.
replacePreviousChar
(
this
.
_prevEditOperationType
,
this
.
context
.
cursorConfig
,
this
.
_model
,
this
.
getSelections
(),
text
,
replaceCharCnt
));
},
eventsCollector
,
source
);
}
public
paste
(
eventsCollector
:
ViewEventsCollector
,
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
?:
string
[]
|
null
|
undefined
,
source
?:
string
|
null
|
undefined
):
void
{
public
paste
(
eventsCollector
:
View
Model
EventsCollector
,
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
?:
string
[]
|
null
|
undefined
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
TypeOperations
.
paste
(
this
.
context
.
cursorConfig
,
this
.
_model
,
this
.
getSelections
(),
text
,
pasteOnNewLine
,
multicursorText
||
[]));
},
eventsCollector
,
source
,
CursorChangeReason
.
Paste
);
}
public
cut
(
eventsCollector
:
ViewEventsCollector
,
source
?:
string
|
null
|
undefined
):
void
{
public
cut
(
eventsCollector
:
View
Model
EventsCollector
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
DeleteOperations
.
cut
(
this
.
context
.
cursorConfig
,
this
.
_model
,
this
.
getSelections
()));
},
eventsCollector
,
source
);
}
public
executeCommand
(
eventsCollector
:
ViewEventsCollector
,
command
:
editorCommon
.
ICommand
,
source
?:
string
|
null
|
undefined
):
void
{
public
executeCommand
(
eventsCollector
:
View
Model
EventsCollector
,
command
:
editorCommon
.
ICommand
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_cursors
.
killSecondaryCursors
();
...
...
@@ -735,7 +691,7 @@ export class Cursor extends Disposable {
},
eventsCollector
,
source
);
}
public
executeCommands
(
eventsCollector
:
ViewEventsCollector
,
commands
:
editorCommon
.
ICommand
[],
source
?:
string
|
null
|
undefined
):
void
{
public
executeCommands
(
eventsCollector
:
View
Model
EventsCollector
,
commands
:
editorCommon
.
ICommand
[],
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
new
EditOperationResult
(
EditOperationType
.
Other
,
commands
,
{
shouldPushStackElementBefore
:
false
,
...
...
src/vs/editor/common/view/viewEvents.ts
浏览文件 @
a8fe75f0
...
...
@@ -302,24 +302,3 @@ export type ViewEvent = (
|
ViewTokensColorsChangedEvent
|
ViewZonesChangedEvent
);
export
class
ViewEventsCollector
{
private
_events
:
ViewEvent
[];
private
_eventsLen
=
0
;
constructor
()
{
this
.
_events
=
[];
this
.
_eventsLen
=
0
;
}
public
emit
(
event
:
ViewEvent
)
{
this
.
_events
[
this
.
_eventsLen
++
]
=
event
;
}
public
finalize
():
ViewEvent
[]
{
let
result
=
this
.
_events
;
this
.
_events
=
[];
return
result
;
}
}
src/vs/editor/common/viewModel/viewModelEventDispatcher.ts
浏览文件 @
a8fe75f0
...
...
@@ -4,10 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
import
{
ViewEvent
,
ViewEventsCollector
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ViewEvent
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IContentSizeChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
export
class
ViewModelEventDispatcher
extends
Disposable
{
...
...
@@ -17,7 +19,7 @@ export class ViewModelEventDispatcher extends Disposable {
private
readonly
_eventHandlers
:
ViewEventHandler
[];
private
_viewEventQueue
:
ViewEvent
[]
|
null
;
private
_isConsumingViewEventQueue
:
boolean
;
private
_collector
:
ViewEventsCollector
|
null
;
private
_collector
:
View
Model
EventsCollector
|
null
;
private
_collectorCnt
:
number
;
private
_outgoingEvents
:
OutgoingViewModelEvent
[];
...
...
@@ -79,10 +81,10 @@ export class ViewModelEventDispatcher extends Disposable {
}
}
public
beginEmitViewEvents
():
ViewEventsCollector
{
public
beginEmitViewEvents
():
View
Model
EventsCollector
{
this
.
_collectorCnt
++
;
if
(
this
.
_collectorCnt
===
1
)
{
this
.
_collector
=
new
ViewEventsCollector
();
this
.
_collector
=
new
View
Model
EventsCollector
();
}
return
this
.
_collector
!
;
}
...
...
@@ -90,10 +92,16 @@ export class ViewModelEventDispatcher extends Disposable {
public
endEmitViewEvents
():
void
{
this
.
_collectorCnt
--
;
if
(
this
.
_collectorCnt
===
0
)
{
const
events
=
this
.
_collector
!
.
finalize
();
const
outgoingEvents
=
this
.
_collector
!
.
outgoingEvents
;
const
viewEvents
=
this
.
_collector
!
.
viewEvents
;
this
.
_collector
=
null
;
if
(
events
.
length
>
0
)
{
this
.
_emitMany
(
events
);
for
(
const
outgoingEvent
of
outgoingEvents
)
{
this
.
_addOutgoingEvent
(
outgoingEvent
);
}
if
(
viewEvents
.
length
>
0
)
{
this
.
_emitMany
(
viewEvents
);
}
}
this
.
_emitOugoingEvents
();
...
...
@@ -102,7 +110,7 @@ export class ViewModelEventDispatcher extends Disposable {
public
emitSingleViewEvent
(
event
:
ViewEvent
):
void
{
try
{
const
eventsCollector
=
this
.
beginEmitViewEvents
();
eventsCollector
.
emit
(
event
);
eventsCollector
.
emit
ViewEvent
(
event
);
}
finally
{
this
.
endEmitViewEvents
();
}
...
...
@@ -144,11 +152,31 @@ export class ViewModelEventDispatcher extends Disposable {
}
}
export
class
ViewModelEventsCollector
{
public
readonly
viewEvents
:
ViewEvent
[];
public
readonly
outgoingEvents
:
OutgoingViewModelEvent
[];
constructor
()
{
this
.
viewEvents
=
[];
this
.
outgoingEvents
=
[];
}
public
emitViewEvent
(
event
:
ViewEvent
)
{
this
.
viewEvents
.
push
(
event
);
}
public
emitOutgoingEvent
(
e
:
OutgoingViewModelEvent
):
void
{
this
.
outgoingEvents
.
push
(
e
);
}
}
export
const
enum
OutgoingViewModelEventKind
{
ContentSizeChanged
,
FocusChanged
,
ScrollChanged
,
ViewZonesChanged
,
CursorStateChanged
,
}
export
class
ContentSizeChangedEvent
implements
IContentSizeChangedEvent
{
...
...
@@ -279,9 +307,69 @@ export class ViewZonesChangedEvent {
}
}
export
class
CursorStateChangedEvent
{
public
readonly
kind
=
OutgoingViewModelEventKind
.
CursorStateChanged
;
public
readonly
oldSelections
:
Selection
[]
|
null
;
public
readonly
selections
:
Selection
[];
public
readonly
oldModelVersionId
:
number
;
public
readonly
modelVersionId
:
number
;
public
readonly
source
:
string
;
public
readonly
reason
:
CursorChangeReason
;
public
readonly
reachedMaxCursorCount
:
boolean
;
constructor
(
oldSelections
:
Selection
[]
|
null
,
selections
:
Selection
[],
oldModelVersionId
:
number
,
modelVersionId
:
number
,
source
:
string
,
reason
:
CursorChangeReason
,
reachedMaxCursorCount
:
boolean
)
{
this
.
oldSelections
=
oldSelections
;
this
.
selections
=
selections
;
this
.
oldModelVersionId
=
oldModelVersionId
;
this
.
modelVersionId
=
modelVersionId
;
this
.
source
=
source
;
this
.
reason
=
reason
;
this
.
reachedMaxCursorCount
=
reachedMaxCursorCount
;
}
private
static
_selectionsAreEqual
(
a
:
Selection
[]
|
null
,
b
:
Selection
[]
|
null
):
boolean
{
if
(
!
a
&&
!
b
)
{
return
true
;
}
if
(
!
a
||
!
b
)
{
return
false
;
}
const
aLen
=
a
.
length
;
const
bLen
=
b
.
length
;
if
(
aLen
!==
bLen
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
aLen
;
i
++
)
{
if
(
!
a
[
i
].
equalsSelection
(
b
[
i
]))
{
return
false
;
}
}
return
true
;
}
public
isNoOp
():
boolean
{
return
(
CursorStateChangedEvent
.
_selectionsAreEqual
(
this
.
oldSelections
,
this
.
selections
)
&&
this
.
oldModelVersionId
===
this
.
modelVersionId
);
}
public
merge
(
other
:
OutgoingViewModelEvent
):
CursorStateChangedEvent
{
if
(
other
.
kind
!==
OutgoingViewModelEventKind
.
CursorStateChanged
)
{
return
this
;
}
return
new
CursorStateChangedEvent
(
this
.
oldSelections
,
other
.
selections
,
this
.
oldModelVersionId
,
other
.
modelVersionId
,
other
.
source
,
other
.
reason
,
this
.
reachedMaxCursorCount
||
other
.
reachedMaxCursorCount
);
}
}
export
type
OutgoingViewModelEvent
=
(
ContentSizeChangedEvent
|
FocusChangedEvent
|
ScrollChangedEvent
|
ViewZonesChangedEvent
|
CursorStateChangedEvent
);
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
a8fe75f0
...
...
@@ -30,7 +30,7 @@ import { Cursor } from 'vs/editor/common/controller/cursor';
import
{
PartialCursorState
,
CursorState
,
IColumnSelectData
,
EditOperationType
,
CursorConfiguration
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
ViewModelEventDispatcher
,
OutgoingViewModelEvent
,
FocusChangedEvent
,
ScrollChangedEvent
,
ViewZonesChangedEvent
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
import
{
ViewModelEventDispatcher
,
OutgoingViewModelEvent
,
FocusChangedEvent
,
ScrollChangedEvent
,
ViewZonesChangedEvent
,
ViewModelEventsCollector
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
const
USE_IDENTITY_LINES_COLLECTION
=
true
;
...
...
@@ -183,7 +183,7 @@ export class ViewModel extends Disposable implements IViewModel {
this
.
_eventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewThemeChangedEvent
());
}
private
_onConfigurationChanged
(
eventsCollector
:
viewEvents
.
View
EventsCollector
,
e
:
ConfigurationChangedEvent
):
void
{
private
_onConfigurationChanged
(
eventsCollector
:
ViewModel
EventsCollector
,
e
:
ConfigurationChangedEvent
):
void
{
// We might need to restore the current centered view range, so save it (if available)
let
previousViewportStartModelPosition
:
Position
|
null
=
null
;
...
...
@@ -200,9 +200,9 @@ export class ViewModel extends Disposable implements IViewModel {
const
wrappingIndent
=
options
.
get
(
EditorOption
.
wrappingIndent
);
if
(
this
.
lines
.
setWrappingSettings
(
fontInfo
,
wrappingStrategy
,
wrappingInfo
.
wrappingColumn
,
wrappingIndent
))
{
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
...
...
@@ -218,10 +218,10 @@ export class ViewModel extends Disposable implements IViewModel {
if
(
e
.
hasChanged
(
EditorOption
.
readOnly
))
{
// Must read again all decorations due to readOnly filtering
this
.
decorations
.
reset
();
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
}
eventsCollector
.
emit
(
new
viewEvents
.
ViewConfigurationChangedEvent
(
e
));
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewConfigurationChangedEvent
(
e
));
this
.
viewLayout
.
onConfigurationChanged
(
e
);
if
(
restorePreviousViewportStart
&&
previousViewportStartModelPosition
)
{
...
...
@@ -272,7 +272,7 @@ export class ViewModel extends Disposable implements IViewModel {
switch
(
change
.
changeType
)
{
case
textModelEvents
.
RawContentChangedType
.
Flush
:
{
this
.
lines
.
onModelFlushed
();
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewFlushedEvent
());
this
.
decorations
.
reset
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
hadOtherModelChange
=
true
;
...
...
@@ -281,7 +281,7 @@ export class ViewModel extends Disposable implements IViewModel {
case
textModelEvents
.
RawContentChangedType
.
LinesDeleted
:
{
const
linesDeletedEvent
=
this
.
lines
.
onModelLinesDeleted
(
versionId
,
change
.
fromLineNumber
,
change
.
toLineNumber
);
if
(
linesDeletedEvent
!==
null
)
{
eventsCollector
.
emit
(
linesDeletedEvent
);
eventsCollector
.
emit
ViewEvent
(
linesDeletedEvent
);
this
.
viewLayout
.
onLinesDeleted
(
linesDeletedEvent
.
fromLineNumber
,
linesDeletedEvent
.
toLineNumber
);
}
hadOtherModelChange
=
true
;
...
...
@@ -293,7 +293,7 @@ export class ViewModel extends Disposable implements IViewModel {
const
linesInsertedEvent
=
this
.
lines
.
onModelLinesInserted
(
versionId
,
change
.
fromLineNumber
,
change
.
toLineNumber
,
insertedLineBreaks
);
if
(
linesInsertedEvent
!==
null
)
{
eventsCollector
.
emit
(
linesInsertedEvent
);
eventsCollector
.
emit
ViewEvent
(
linesInsertedEvent
);
this
.
viewLayout
.
onLinesInserted
(
linesInsertedEvent
.
fromLineNumber
,
linesInsertedEvent
.
toLineNumber
);
}
hadOtherModelChange
=
true
;
...
...
@@ -306,14 +306,14 @@ export class ViewModel extends Disposable implements IViewModel {
const
[
lineMappingChanged
,
linesChangedEvent
,
linesInsertedEvent
,
linesDeletedEvent
]
=
this
.
lines
.
onModelLineChanged
(
versionId
,
change
.
lineNumber
,
changedLineBreakData
);
hadModelLineChangeThatChangedLineMapping
=
lineMappingChanged
;
if
(
linesChangedEvent
)
{
eventsCollector
.
emit
(
linesChangedEvent
);
eventsCollector
.
emit
ViewEvent
(
linesChangedEvent
);
}
if
(
linesInsertedEvent
)
{
eventsCollector
.
emit
(
linesInsertedEvent
);
eventsCollector
.
emit
ViewEvent
(
linesInsertedEvent
);
this
.
viewLayout
.
onLinesInserted
(
linesInsertedEvent
.
fromLineNumber
,
linesInsertedEvent
.
toLineNumber
);
}
if
(
linesDeletedEvent
)
{
eventsCollector
.
emit
(
linesDeletedEvent
);
eventsCollector
.
emit
ViewEvent
(
linesDeletedEvent
);
this
.
viewLayout
.
onLinesDeleted
(
linesDeletedEvent
.
fromLineNumber
,
linesDeletedEvent
.
toLineNumber
);
}
break
;
...
...
@@ -328,8 +328,8 @@ export class ViewModel extends Disposable implements IViewModel {
this
.
viewLayout
.
onHeightMaybeChanged
();
if
(
!
hadOtherModelChange
&&
hadModelLineChangeThatChangedLineMapping
)
{
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
}
...
...
@@ -394,9 +394,9 @@ export class ViewModel extends Disposable implements IViewModel {
if
(
this
.
lines
.
setTabSize
(
this
.
model
.
getOptions
().
tabSize
))
{
try
{
const
eventsCollector
=
this
.
_eventDispatcher
.
beginEmitViewEvents
();
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
...
...
@@ -421,9 +421,9 @@ export class ViewModel extends Disposable implements IViewModel {
const
eventsCollector
=
this
.
_eventDispatcher
.
beginEmitViewEvents
();
let
lineMappingChanged
=
this
.
lines
.
setHiddenAreas
(
ranges
);
if
(
lineMappingChanged
)
{
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
...
...
@@ -947,15 +947,15 @@ export class ViewModel extends Disposable implements IViewModel {
public
revealTopMostCursor
(
source
:
string
|
null
|
undefined
):
void
{
const
viewPosition
=
this
.
cursor
.
getTopMostViewPosition
();
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
ScrollType
.
Smooth
)));
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
ScrollType
.
Smooth
)));
}
public
revealBottomMostCursor
(
source
:
string
|
null
|
undefined
):
void
{
const
viewPosition
=
this
.
cursor
.
getBottomMostViewPosition
();
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
ScrollType
.
Smooth
)));
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
ScrollType
.
Smooth
)));
}
public
revealRange
(
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
viewRange
:
Range
,
verticalType
:
viewEvents
.
VerticalRevealType
,
scrollType
:
ScrollType
):
void
{
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
verticalType
,
revealHorizontal
,
scrollType
)));
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
ViewEvent
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
verticalType
,
revealHorizontal
,
scrollType
)));
}
//#endregion
...
...
@@ -988,7 +988,7 @@ export class ViewModel extends Disposable implements IViewModel {
}
//#endregion
private
_withViewEventsCollector
(
callback
:
(
eventsCollector
:
viewEvents
.
View
EventsCollector
)
=>
void
):
void
{
private
_withViewEventsCollector
(
callback
:
(
eventsCollector
:
ViewModel
EventsCollector
)
=>
void
):
void
{
try
{
const
eventsCollector
=
this
.
_eventDispatcher
.
beginEmitViewEvents
();
callback
(
eventsCollector
);
...
...
src/vs/editor/test/browser/controller/cursor.test.ts
浏览文件 @
a8fe75f0
...
...
@@ -6,7 +6,6 @@
import
*
as
assert
from
'
assert
'
;
import
{
CoreEditingCommands
,
CoreNavigationCommands
}
from
'
vs/editor/browser/controller/coreCommands
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CursorStateChangedEvent
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
EditOperation
}
from
'
vs/editor/common/core/editOperation
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -24,6 +23,7 @@ import { IRelaxedTextModelCreationOptions, createTextModel } from 'vs/editor/tes
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
javascriptOnEnterRules
}
from
'
vs/editor/test/common/modes/supports/javascriptOnEnterRules
'
;
import
{
ViewModel
}
from
'
vs/editor/common/viewModel/viewModelImpl
'
;
import
{
OutgoingViewModelEventKind
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
// --------- utils
...
...
@@ -782,7 +782,7 @@ suite('Editor Controller - Cursor', () => {
test
(
'
no move doesn
\'
t trigger event
'
,
()
=>
{
runTest
((
editor
,
viewModel
)
=>
{
viewModel
.
cursor
.
onDidChange
((
e
)
=>
{
viewModel
.
onEvent
((
e
)
=>
{
assert
.
ok
(
false
,
'
was not expecting event
'
);
});
moveTo
(
editor
,
viewModel
,
1
,
1
);
...
...
@@ -792,9 +792,13 @@ suite('Editor Controller - Cursor', () => {
test
(
'
move eventing
'
,
()
=>
{
runTest
((
editor
,
viewModel
)
=>
{
let
events
=
0
;
viewModel
.
cursor
.
onDidChange
((
e
:
CursorStateChangedEvent
)
=>
{
viewModel
.
onEvent
((
e
)
=>
{
if
(
e
.
kind
===
OutgoingViewModelEventKind
.
CursorStateChanged
)
{
events
++
;
assert
.
deepEqual
(
e
.
selections
,
[
new
Selection
(
1
,
2
,
1
,
2
)]);
}
else
{
assert
.
ok
(
false
);
}
});
moveTo
(
editor
,
viewModel
,
1
,
2
);
assert
.
equal
(
events
,
1
,
'
receives 1 event
'
);
...
...
@@ -804,9 +808,13 @@ suite('Editor Controller - Cursor', () => {
test
(
'
move in selection mode eventing
'
,
()
=>
{
runTest
((
editor
,
viewModel
)
=>
{
let
events
=
0
;
viewModel
.
cursor
.
onDidChange
((
e
:
CursorStateChangedEvent
)
=>
{
viewModel
.
onEvent
((
e
)
=>
{
if
(
e
.
kind
===
OutgoingViewModelEventKind
.
CursorStateChanged
)
{
events
++
;
assert
.
deepEqual
(
e
.
selections
,
[
new
Selection
(
1
,
1
,
1
,
2
)]);
}
else
{
assert
.
ok
(
false
);
}
});
moveTo
(
editor
,
viewModel
,
1
,
2
,
true
);
assert
.
equal
(
events
,
1
,
'
receives 1 event
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录