Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
aae591bd
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,发现更多精彩内容 >>
提交
aae591bd
编写于
5月 18, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move ViewModelCursors out of the ViewModel
上级
beee645a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
138 addition
and
106 deletion
+138
-106
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+6
-0
src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts
...er/viewParts/currentLineHighlight/currentLineHighlight.ts
+0
-3
src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts
.../currentLineMarginHighlight/currentLineMarginHighlight.ts
+0
-2
src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts
src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts
+0
-6
src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts
src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts
+0
-5
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+1
-0
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+12
-1
src/vs/editor/common/viewModel/viewModelCursors.ts
src/vs/editor/common/viewModel/viewModelCursors.ts
+81
-9
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+38
-80
未找到文件。
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
aae591bd
...
...
@@ -49,6 +49,7 @@ import { EditorScrollbar } from 'vs/editor/browser/viewParts/editorScrollbar/edi
import
{
Minimap
}
from
'
vs/editor/browser/viewParts/minimap/minimap
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IThemeService
,
getThemeTypeSelector
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
ViewModelCursors
}
from
"
vs/editor/common/viewModel/viewModelCursors
"
;
export
interface
IContentWidgetData
{
widget
:
editorBrowser
.
IContentWidget
;
...
...
@@ -97,6 +98,7 @@ export class View extends ViewEventHandler {
configuration
:
Configuration
,
themeService
:
IThemeService
,
model
:
IViewModel
,
cursor
:
ViewModelCursors
,
execCoreEditorCommandFunc
:
ExecCoreEditorCommandFunc
)
{
super
();
...
...
@@ -136,6 +138,10 @@ export class View extends ViewEventHandler {
this
.
_register
(
model
.
addEventListener
((
events
:
viewEvents
.
ViewEvent
[])
=>
{
this
.
eventDispatcher
.
emitMany
(
events
);
}));
this
.
_register
(
cursor
.
addEventListener
((
events
:
viewEvents
.
ViewEvent
[])
=>
{
this
.
eventDispatcher
.
emitMany
(
events
);
}));
}
private
createViewParts
():
void
{
...
...
src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts
浏览文件 @
aae591bd
...
...
@@ -84,9 +84,6 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
return
false
;
}
public
onFlushed
(
e
:
viewEvents
.
ViewFlushedEvent
):
boolean
{
this
.
_primaryCursorIsInEditableRange
=
true
;
this
.
_selectionIsEmpty
=
true
;
this
.
_primaryCursorLineNumber
=
1
;
return
true
;
}
public
onLinesDeleted
(
e
:
viewEvents
.
ViewLinesDeletedEvent
):
boolean
{
...
...
src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts
浏览文件 @
aae591bd
...
...
@@ -67,8 +67,6 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
return
hasChanged
;
}
public
onFlushed
(
e
:
viewEvents
.
ViewFlushedEvent
):
boolean
{
this
.
_primaryCursorIsInEditableRange
=
true
;
this
.
_primaryCursorLineNumber
=
1
;
return
true
;
}
public
onLinesDeleted
(
e
:
viewEvents
.
ViewLinesDeletedEvent
):
boolean
{
...
...
src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts
浏览文件 @
aae591bd
...
...
@@ -130,12 +130,6 @@ export class ViewCursor {
return
true
;
}
public
onFlushed
():
boolean
{
this
.
updatePosition
(
new
Position
(
1
,
1
));
this
.
_isInEditableRange
=
true
;
return
true
;
}
private
_prepareRender
(
ctx
:
RenderingContext
):
ViewCursorRenderData
{
if
(
this
.
_cursorStyle
===
TextEditorCursorStyle
.
Line
||
this
.
_cursorStyle
===
TextEditorCursorStyle
.
LineThin
)
{
const
visibleRange
=
ctx
.
visibleRangeForPosition
(
this
.
_position
);
...
...
src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts
浏览文件 @
aae591bd
...
...
@@ -139,11 +139,6 @@ export class ViewCursors extends ViewPart {
return
true
;
}
public
onFlushed
(
e
:
viewEvents
.
ViewFlushedEvent
):
boolean
{
this
.
_primaryCursor
.
onFlushed
();
for
(
let
i
=
0
,
len
=
this
.
_secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
this
.
_domNode
.
removeChild
(
this
.
_secondaryCursors
[
i
].
getDomNode
());
}
this
.
_secondaryCursors
=
[];
return
true
;
}
public
onFocusChanged
(
e
:
viewEvents
.
ViewFocusChangedEvent
):
boolean
{
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
aae591bd
...
...
@@ -422,6 +422,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
this
.
_configuration
,
this
.
_themeService
,
this
.
viewModel
,
this
.
viewCursor
,
(
editorCommand
:
CoreEditorCommand
,
args
:
any
)
=>
{
if
(
!
this
.
cursor
)
{
return
;
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
aae591bd
...
...
@@ -28,6 +28,7 @@ import {
import
*
as
editorOptions
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CursorEventType
,
ICursorPositionChangedEvent
,
VerticalRevealType
,
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
ViewModelCursors
}
from
"
vs/editor/common/viewModel/viewModelCursors
"
;
let
EDITOR_ID
=
0
;
...
...
@@ -99,6 +100,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
protected
viewModel
:
ViewModel
;
protected
cursor
:
Cursor
;
protected
viewCursor
:
ViewModelCursors
;
protected
readonly
_instantiationService
:
IInstantiationService
;
protected
readonly
_contextKeyService
:
IContextKeyService
;
...
...
@@ -932,7 +934,11 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
this
.
_enableEmptySelectionClipboard
()
);
this
.
viewModel
.
addEventSource
(
this
.
cursor
);
this
.
viewCursor
=
new
ViewModelCursors
(
this
.
_configuration
,
this
.
viewModel
,
this
.
cursor
);
this
.
_createView
();
...
...
@@ -994,6 +1000,11 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
this
.
cursor
=
null
;
}
if
(
this
.
viewCursor
)
{
this
.
viewCursor
.
dispose
();
this
.
viewCursor
=
null
;
}
if
(
this
.
viewModel
)
{
this
.
viewModel
.
dispose
();
this
.
viewModel
=
null
;
...
...
src/vs/editor/common/viewModel/viewModelCursors.ts
浏览文件 @
aae591bd
...
...
@@ -6,10 +6,13 @@
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
ICoordinatesConverter
,
ViewEventsCollector
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
ICoordinatesConverter
,
ViewEventsCollector
,
IViewModel
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ICursorRevealRangeEvent
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
ICursorRevealRangeEvent
,
CursorEventType
,
CursorScrollRequest
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
Cursor
}
from
"
vs/editor/common/controller/cursor
"
;
import
{
ViewEventEmitter
}
from
"
vs/editor/common/viewModel/viewModelImpl
"
;
import
{
EmitterEvent
}
from
"
vs/base/common/eventEmitter
"
;
export
interface
ICursorPositionChangedEvent
{
readonly
position
:
Position
;
...
...
@@ -26,19 +29,88 @@ export interface ICursorSelectionChangedEvent {
readonly
secondaryViewSelections
:
Selection
[];
}
export
class
ViewModelCursors
{
function
containsLineMappingChanged
(
events
:
viewEvents
.
ViewEvent
[]):
boolean
{
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
if
(
events
[
i
].
type
===
viewEvents
.
ViewEventType
.
ViewLineMappingChanged
)
{
return
true
;
}
}
return
false
;
}
export
class
ViewModelCursors
extends
ViewEventEmitter
{
private
readonly
configuration
:
editorCommon
.
IConfiguration
;
private
readonly
viewModel
:
IViewModel
;
private
readonly
cursor
:
Cursor
;
private
readonly
coordinatesConverter
:
ICoordinatesConverter
;
private
lastCursorPositionChangedEvent
:
ICursorPositionChangedEvent
;
private
lastCursorSelectionChangedEvent
:
ICursorSelectionChangedEvent
;
constructor
(
configuration
:
editorCommon
.
IConfiguration
,
coordinatesConverter
:
ICoordinatesConverter
)
{
constructor
(
configuration
:
editorCommon
.
IConfiguration
,
viewModel
:
IViewModel
,
cursor
:
Cursor
)
{
super
();
this
.
configuration
=
configuration
;
this
.
coordinatesConverter
=
coordinatesConverter
;
this
.
viewModel
=
viewModel
;
this
.
cursor
=
cursor
;
this
.
coordinatesConverter
=
viewModel
.
coordinatesConverter
;
this
.
lastCursorPositionChangedEvent
=
null
;
this
.
lastCursorSelectionChangedEvent
=
null
;
this
.
_register
(
cursor
.
addBulkListener
((
events
:
EmitterEvent
[])
=>
{
const
eventsCollector
=
new
ViewEventsCollector
();
this
.
_onCursorEvents
(
eventsCollector
,
events
);
this
.
_emit
(
eventsCollector
.
finalize
());
}));
this
.
_register
(
viewModel
.
addEventListener
((
events
:
viewEvents
.
ViewEvent
[])
=>
{
if
(
!
containsLineMappingChanged
(
events
))
{
return
;
}
const
eventsCollector
=
new
ViewEventsCollector
();
this
.
onLineMappingChanged
(
eventsCollector
);
this
.
_emit
(
eventsCollector
.
finalize
());
}));
}
private
_onCursorEvents
(
eventsCollector
:
ViewEventsCollector
,
events
:
EmitterEvent
[]):
void
{
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
const
_e
=
events
[
i
];
const
type
=
_e
.
type
;
const
data
=
_e
.
data
;
switch
(
type
)
{
case
CursorEventType
.
CursorPositionChanged
:
{
const
e
=
<
ICursorPositionChangedEvent
>
data
;
this
.
onCursorPositionChanged
(
eventsCollector
,
e
);
break
;
}
case
CursorEventType
.
CursorSelectionChanged
:
{
const
e
=
<
ICursorSelectionChangedEvent
>
data
;
this
.
onCursorSelectionChanged
(
eventsCollector
,
e
);
break
;
}
case
CursorEventType
.
CursorRevealRange
:
{
const
e
=
<
ICursorRevealRangeEvent
>
data
;
this
.
onCursorRevealRange
(
eventsCollector
,
e
);
break
;
}
case
CursorEventType
.
CursorScrollRequest
:
{
const
e
=
<
CursorScrollRequest
>
data
;
this
.
viewModel
.
viewLayout
.
setScrollPosition
({
scrollTop
:
e
.
desiredScrollTop
});
break
;
}
default
:
console
.
info
(
'
View received unknown event:
'
);
console
.
info
(
type
,
data
);
}
}
}
public
dispose
():
void
{
super
.
dispose
();
}
/**
...
...
@@ -52,7 +124,7 @@ export class ViewModelCursors {
return
position
;
}
p
ublic
onCursorPositionChanged
(
eventsCollector
:
ViewEventsCollector
,
e
:
ICursorPositionChangedEvent
):
void
{
p
rivate
onCursorPositionChanged
(
eventsCollector
:
ViewEventsCollector
,
e
:
ICursorPositionChangedEvent
):
void
{
this
.
lastCursorPositionChangedEvent
=
e
;
const
stopRenderingLineAfter
=
this
.
configuration
.
editor
.
viewInfo
.
stopRenderingLineAfter
;
...
...
@@ -66,13 +138,13 @@ export class ViewModelCursors {
eventsCollector
.
emit
(
new
viewEvents
.
ViewCursorPositionChangedEvent
(
position
,
secondaryPositions
,
e
.
isInEditableRange
));
}
p
ublic
onCursorSelectionChanged
(
eventsCollector
:
ViewEventsCollector
,
e
:
ICursorSelectionChangedEvent
):
void
{
p
rivate
onCursorSelectionChanged
(
eventsCollector
:
ViewEventsCollector
,
e
:
ICursorSelectionChangedEvent
):
void
{
this
.
lastCursorSelectionChangedEvent
=
e
;
eventsCollector
.
emit
(
new
viewEvents
.
ViewCursorSelectionChangedEvent
(
e
.
viewSelection
,
e
.
secondaryViewSelections
));
}
p
ublic
onCursorRevealRange
(
eventsCollector
:
ViewEventsCollector
,
e
:
ICursorRevealRangeEvent
):
void
{
p
rivate
onCursorRevealRange
(
eventsCollector
:
ViewEventsCollector
,
e
:
ICursorRevealRangeEvent
):
void
{
// Ensure event has viewRange
const
viewRange
=
(
e
.
viewRange
...
...
@@ -86,7 +158,7 @@ export class ViewModelCursors {
));
}
p
ublic
onLineMappingChanged
(
eventsCollector
:
ViewEventsCollector
):
void
{
p
rivate
onLineMappingChanged
(
eventsCollector
:
ViewEventsCollector
):
void
{
if
(
this
.
lastCursorPositionChangedEvent
)
{
const
toViewPos
=
(
pos
:
Position
)
=>
this
.
coordinatesConverter
.
convertModelPositionToViewPosition
(
pos
);
let
e
:
ICursorPositionChangedEvent
=
{
...
...
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
aae591bd
...
...
@@ -13,7 +13,6 @@ import { Selection } from 'vs/editor/common/core/selection';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
TokenizationRegistry
,
ColorId
,
LanguageId
}
from
'
vs/editor/common/modes
'
;
import
{
tokenizeLineToHTML
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
import
{
ViewModelCursors
}
from
'
vs/editor/common/viewModel/viewModelCursors
'
;
import
{
ViewModelDecorations
}
from
'
vs/editor/common/viewModel/viewModelDecorations
'
;
import
{
MinimapLinesRenderingData
,
ViewLineRenderingData
,
ViewModelDecoration
,
IViewModelListener
,
IViewModel
,
ICoordinatesConverter
,
ViewEventsCollector
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
SplitLinesCollection
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
...
...
@@ -22,8 +21,7 @@ import * as errors from 'vs/base/common/errors';
import
{
MinimapTokensColorTracker
}
from
'
vs/editor/common/view/minimapCharRenderer
'
;
import
*
as
textModelEvents
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
IConfigurationChangedEvent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CursorEventType
,
ICursorPositionChangedEvent
,
VerticalRevealType
,
ICursorSelectionChangedEvent
,
ICursorRevealRangeEvent
,
CursorScrollRequest
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
VerticalRevealType
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
CharacterHardWrappingLineMapperFactory
}
from
"
vs/editor/common/viewModel/characterHardWrappingLineMapper
"
;
import
{
ViewLayout
}
from
'
vs/editor/common/viewLayout/viewLayout
'
;
...
...
@@ -87,7 +85,43 @@ export class CoordinatesConverter implements ICoordinatesConverter {
}
export
class
ViewModel
extends
Disposable
implements
IViewModel
{
export
class
ViewEventEmitter
extends
Disposable
{
private
_listeners
:
IViewModelListener
[];
constructor
()
{
super
();
this
.
_listeners
=
[];
}
public
dispose
():
void
{
this
.
_listeners
=
[];
super
.
dispose
();
}
protected
_emit
(
events
:
viewEvents
.
ViewEvent
[]):
void
{
const
listeners
=
this
.
_listeners
.
slice
(
0
);
for
(
let
i
=
0
,
len
=
listeners
.
length
;
i
<
len
;
i
++
)
{
safeInvokeListener
(
listeners
[
i
],
events
);
}
}
public
addEventListener
(
listener
:
(
events
:
viewEvents
.
ViewEvent
[])
=>
void
):
IDisposable
{
this
.
_listeners
.
push
(
listener
);
return
{
dispose
:
()
=>
{
let
listeners
=
this
.
_listeners
;
for
(
let
i
=
0
,
len
=
listeners
.
length
;
i
<
len
;
i
++
)
{
if
(
listeners
[
i
]
===
listener
)
{
listeners
.
splice
(
i
,
1
);
break
;
}
}
}
};
}
}
export
class
ViewModel
extends
ViewEventEmitter
implements
IViewModel
{
private
readonly
editorId
:
number
;
private
readonly
configuration
:
editorCommon
.
IConfiguration
;
...
...
@@ -97,11 +131,9 @@ export class ViewModel extends Disposable implements IViewModel {
public
readonly
viewLayout
:
ViewLayout
;
private
readonly
decorations
:
ViewModelDecorations
;
private
readonly
cursors
:
ViewModelCursors
;
private
_isDisposing
:
boolean
;
private
_centeredViewLine
:
number
;
private
_listeners
:
IViewModelListener
[];
constructor
(
editorId
:
number
,
configuration
:
editorCommon
.
IConfiguration
,
model
:
editorCommon
.
IModel
)
{
super
();
...
...
@@ -139,12 +171,9 @@ export class ViewModel extends Disposable implements IViewModel {
this
.
_isDisposing
=
false
;
this
.
_centeredViewLine
=
-
1
;
this
.
_listeners
=
[];
this
.
decorations
=
new
ViewModelDecorations
(
this
.
editorId
,
this
.
model
,
this
.
configuration
,
this
.
coordinatesConverter
);
this
.
cursors
=
new
ViewModelCursors
(
this
.
configuration
,
this
.
coordinatesConverter
);
this
.
_register
(
this
.
model
.
addBulkListener
((
events
:
EmitterEvent
[])
=>
{
if
(
this
.
_isDisposing
)
{
// Disposing the lines might end up sending model decoration changed events
...
...
@@ -171,61 +200,9 @@ export class ViewModel extends Disposable implements IViewModel {
this
.
_isDisposing
=
true
;
this
.
decorations
.
dispose
();
this
.
lines
.
dispose
();
this
.
_listeners
=
[];
super
.
dispose
();
}
private
_emit
(
events
:
viewEvents
.
ViewEvent
[]):
void
{
const
listeners
=
this
.
_listeners
.
slice
(
0
);
for
(
let
i
=
0
,
len
=
listeners
.
length
;
i
<
len
;
i
++
)
{
safeInvokeListener
(
listeners
[
i
],
events
);
}
}
public
addEventSource
(
cursor
:
Cursor
):
void
{
this
.
_register
(
cursor
.
addBulkListener
((
events
:
EmitterEvent
[])
=>
{
const
eventsCollector
=
new
ViewEventsCollector
();
this
.
_onCursorEvents
(
eventsCollector
,
events
);
this
.
_emit
(
eventsCollector
.
finalize
());
}));
}
private
_onCursorEvents
(
eventsCollector
:
ViewEventsCollector
,
events
:
EmitterEvent
[]):
void
{
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
const
_e
=
events
[
i
];
const
type
=
_e
.
type
;
const
data
=
_e
.
data
;
switch
(
type
)
{
case
CursorEventType
.
CursorPositionChanged
:
{
const
e
=
<
ICursorPositionChangedEvent
>
data
;
this
.
cursors
.
onCursorPositionChanged
(
eventsCollector
,
e
);
break
;
}
case
CursorEventType
.
CursorSelectionChanged
:
{
const
e
=
<
ICursorSelectionChangedEvent
>
data
;
this
.
cursors
.
onCursorSelectionChanged
(
eventsCollector
,
e
);
break
;
}
case
CursorEventType
.
CursorRevealRange
:
{
const
e
=
<
ICursorRevealRangeEvent
>
data
;
this
.
cursors
.
onCursorRevealRange
(
eventsCollector
,
e
);
break
;
}
case
CursorEventType
.
CursorScrollRequest
:
{
const
e
=
<
CursorScrollRequest
>
data
;
this
.
viewLayout
.
setScrollPosition
({
scrollTop
:
e
.
desiredScrollTop
});
break
;
}
default
:
console
.
info
(
'
View received unknown event:
'
);
console
.
info
(
type
,
data
);
}
}
}
private
_onConfigurationChanged
(
eventsCollector
:
ViewEventsCollector
,
e
:
IConfigurationChangedEvent
):
void
{
// We might need to restore the current centered view range, so save it (if available)
...
...
@@ -238,7 +215,6 @@ export class ViewModel extends Disposable implements IViewModel {
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
this
.
decorations
.
onLineMappingChanged
(
eventsCollector
);
this
.
cursors
.
onLineMappingChanged
(
eventsCollector
);
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
revealPreviousCenteredModelRange
=
true
;
}
...
...
@@ -377,7 +353,6 @@ export class ViewModel extends Disposable implements IViewModel {
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
this
.
decorations
.
onLineMappingChanged
(
eventsCollector
);
this
.
cursors
.
onLineMappingChanged
(
eventsCollector
);
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
}
...
...
@@ -401,7 +376,6 @@ export class ViewModel extends Disposable implements IViewModel {
if
(
!
hadOtherModelChange
&&
hadModelLineChangeThatChangedLineMapping
)
{
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
this
.
decorations
.
onLineMappingChanged
(
eventsCollector
);
this
.
cursors
.
onLineMappingChanged
(
eventsCollector
);
}
}
...
...
@@ -412,27 +386,11 @@ export class ViewModel extends Disposable implements IViewModel {
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
this
.
decorations
.
onLineMappingChanged
(
eventsCollector
);
this
.
cursors
.
onLineMappingChanged
(
eventsCollector
);
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
}
this
.
_emit
(
eventsCollector
.
finalize
());
}
public
addEventListener
(
listener
:
(
events
:
viewEvents
.
ViewEvent
[])
=>
void
):
IDisposable
{
this
.
_listeners
.
push
(
listener
);
return
{
dispose
:
()
=>
{
let
listeners
=
this
.
_listeners
;
for
(
let
i
=
0
,
len
=
listeners
.
length
;
i
<
len
;
i
++
)
{
if
(
listeners
[
i
]
===
listener
)
{
listeners
.
splice
(
i
,
1
);
break
;
}
}
}
};
}
public
getCenteredRangeInViewport
():
Range
{
if
(
this
.
_centeredViewLine
===
-
1
)
{
// Never got rendered or not rendered since last content change event
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录