Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1620c36f
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,发现更多精彩内容 >>
未验证
提交
1620c36f
编写于
5月 20, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Emit the content size changed event through the view model
上级
6ff4290a
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
149 addition
and
147 deletion
+149
-147
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+0
-4
src/vs/editor/browser/view/viewOutgoingEvents.ts
src/vs/editor/browser/view/viewOutgoingEvents.ts
+1
-8
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+9
-1
src/vs/editor/common/view/viewEvents.ts
src/vs/editor/common/view/viewEvents.ts
+17
-84
src/vs/editor/common/viewLayout/viewLayout.ts
src/vs/editor/common/viewLayout/viewLayout.ts
+9
-11
src/vs/editor/common/viewModel/viewEventHandler.ts
src/vs/editor/common/viewModel/viewEventHandler.ts
+1
-9
src/vs/editor/common/viewModel/viewModelEventDispatcher.ts
src/vs/editor/common/viewModel/viewModelEventDispatcher.ts
+84
-6
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+28
-24
未找到文件。
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
1620c36f
...
@@ -299,10 +299,6 @@ export class View extends ViewEventHandler {
...
@@ -299,10 +299,6 @@ export class View extends ViewEventHandler {
this
.
_applyLayout
();
this
.
_applyLayout
();
return
false
;
return
false
;
}
}
public
onContentSizeChanged
(
e
:
viewEvents
.
ViewContentSizeChangedEvent
):
boolean
{
this
.
outgoingEvents
.
emitContentSizeChange
(
e
);
return
false
;
}
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
this
.
_selections
=
e
.
selections
;
this
.
_selections
=
e
.
selections
;
return
false
;
return
false
;
...
...
src/vs/editor/browser/view/viewOutgoingEvents.ts
浏览文件 @
1620c36f
...
@@ -9,7 +9,7 @@ import { MouseTarget } from 'vs/editor/browser/controller/mouseTarget';
...
@@ -9,7 +9,7 @@ import { MouseTarget } from 'vs/editor/browser/controller/mouseTarget';
import
{
IEditorMouseEvent
,
IMouseTarget
,
IPartialEditorMouseEvent
,
MouseTargetType
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IEditorMouseEvent
,
IMouseTarget
,
IPartialEditorMouseEvent
,
MouseTargetType
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IScrollEvent
,
IContentSizeChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IScrollEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IViewModel
,
ICoordinatesConverter
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
IViewModel
,
ICoordinatesConverter
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
IMouseWheelEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
IMouseWheelEvent
}
from
'
vs/base/browser/mouseEvent
'
;
...
@@ -20,7 +20,6 @@ export interface EventCallback<T> {
...
@@ -20,7 +20,6 @@ export interface EventCallback<T> {
export
class
ViewOutgoingEvents
extends
Disposable
{
export
class
ViewOutgoingEvents
extends
Disposable
{
public
onDidContentSizeChange
:
EventCallback
<
IContentSizeChangedEvent
>
|
null
=
null
;
public
onDidScroll
:
EventCallback
<
IScrollEvent
>
|
null
=
null
;
public
onDidScroll
:
EventCallback
<
IScrollEvent
>
|
null
=
null
;
public
onDidGainFocus
:
EventCallback
<
void
>
|
null
=
null
;
public
onDidGainFocus
:
EventCallback
<
void
>
|
null
=
null
;
public
onDidLoseFocus
:
EventCallback
<
void
>
|
null
=
null
;
public
onDidLoseFocus
:
EventCallback
<
void
>
|
null
=
null
;
...
@@ -42,12 +41,6 @@ export class ViewOutgoingEvents extends Disposable {
...
@@ -42,12 +41,6 @@ export class ViewOutgoingEvents extends Disposable {
this
.
_viewModel
=
viewModel
;
this
.
_viewModel
=
viewModel
;
}
}
public
emitContentSizeChange
(
e
:
viewEvents
.
ViewContentSizeChangedEvent
):
void
{
if
(
this
.
onDidContentSizeChange
)
{
this
.
onDidContentSizeChange
(
e
);
}
}
public
emitScrollChanged
(
e
:
viewEvents
.
ViewScrollChangedEvent
):
void
{
public
emitScrollChanged
(
e
:
viewEvents
.
ViewScrollChangedEvent
):
void
{
if
(
this
.
onDidScroll
)
{
if
(
this
.
onDidScroll
)
{
this
.
onDidScroll
(
e
);
this
.
onDidScroll
(
e
);
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
1620c36f
...
@@ -54,6 +54,7 @@ import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/m
...
@@ -54,6 +54,7 @@ import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/m
import
{
DOMLineBreaksComputerFactory
}
from
'
vs/editor/browser/view/domLineBreaksComputer
'
;
import
{
DOMLineBreaksComputerFactory
}
from
'
vs/editor/browser/view/domLineBreaksComputer
'
;
import
{
WordOperations
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
import
{
WordOperations
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
import
{
IViewModel
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
IViewModel
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
OutgoingViewModelEventKind
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
let
EDITOR_ID
=
0
;
let
EDITOR_ID
=
0
;
...
@@ -1509,6 +1510,14 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
...
@@ -1509,6 +1510,14 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
this
.
_onDidChangeCursorSelection
.
fire
(
e2
);
this
.
_onDidChangeCursorSelection
.
fire
(
e2
);
}));
}));
listenersToRemove
.
push
(
viewModel
.
onEvent
((
e
)
=>
{
switch
(
e
.
kind
)
{
case
OutgoingViewModelEventKind
.
ContentSizeChanged
:
this
.
_onDidContentSizeChange
.
fire
(
e
);
break
;
}
}));
const
[
view
,
hasRealView
]
=
this
.
_createView
(
viewModel
);
const
[
view
,
hasRealView
]
=
this
.
_createView
(
viewModel
);
if
(
hasRealView
)
{
if
(
hasRealView
)
{
this
.
_domElement
.
appendChild
(
view
.
domNode
.
domNode
);
this
.
_domElement
.
appendChild
(
view
.
domNode
.
domNode
);
...
@@ -1592,7 +1601,6 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
...
@@ -1592,7 +1601,6 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
};
};
const
viewOutgoingEvents
=
new
ViewOutgoingEvents
(
viewModel
);
const
viewOutgoingEvents
=
new
ViewOutgoingEvents
(
viewModel
);
viewOutgoingEvents
.
onDidContentSizeChange
=
(
e
)
=>
this
.
_onDidContentSizeChange
.
fire
(
e
);
viewOutgoingEvents
.
onDidScroll
=
(
e
)
=>
this
.
_onDidScrollChange
.
fire
(
e
);
viewOutgoingEvents
.
onDidScroll
=
(
e
)
=>
this
.
_onDidScrollChange
.
fire
(
e
);
viewOutgoingEvents
.
onDidGainFocus
=
()
=>
onDidChangeTextFocus
(
true
);
viewOutgoingEvents
.
onDidGainFocus
=
()
=>
onDidChangeTextFocus
(
true
);
viewOutgoingEvents
.
onDidLoseFocus
=
()
=>
onDidChangeTextFocus
(
false
);
viewOutgoingEvents
.
onDidLoseFocus
=
()
=>
onDidChangeTextFocus
(
false
);
...
...
src/vs/editor/common/view/viewEvents.ts
浏览文件 @
1620c36f
...
@@ -3,33 +3,30 @@
...
@@ -3,33 +3,30 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
ViewModelEventDispatcher
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ScrollEvent
}
from
'
vs/base/common/scrollable
'
;
import
{
ScrollEvent
}
from
'
vs/base/common/scrollable
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ScrollType
,
IContentSizeChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IModelDecorationsChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
IModelDecorationsChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
export
const
enum
ViewEventType
{
export
const
enum
ViewEventType
{
ViewConfigurationChanged
=
1
,
ViewConfigurationChanged
,
ViewContentSizeChanged
=
2
,
ViewCursorStateChanged
,
ViewCursorStateChanged
=
3
,
ViewDecorationsChanged
,
ViewDecorationsChanged
=
4
,
ViewFlushed
,
ViewFlushed
=
5
,
ViewFocusChanged
,
ViewFocusChanged
=
6
,
ViewLanguageConfigurationChanged
,
ViewLanguageConfigurationChanged
=
7
,
ViewLineMappingChanged
,
ViewLineMappingChanged
=
8
,
ViewLinesChanged
,
ViewLinesChanged
=
9
,
ViewLinesDeleted
,
ViewLinesDeleted
=
10
,
ViewLinesInserted
,
ViewLinesInserted
=
11
,
ViewRevealRangeRequest
,
ViewRevealRangeRequest
=
12
,
ViewScrollChanged
,
ViewScrollChanged
=
13
,
ViewThemeChanged
,
ViewThemeChanged
=
14
,
ViewTokensChanged
,
ViewTokensChanged
=
15
,
ViewTokensColorsChanged
,
ViewTokensColorsChanged
=
16
,
ViewZonesChanged
,
ViewZonesChanged
=
17
,
}
}
export
class
ViewConfigurationChangedEvent
{
export
class
ViewConfigurationChangedEvent
{
...
@@ -47,25 +44,6 @@ export class ViewConfigurationChangedEvent {
...
@@ -47,25 +44,6 @@ export class ViewConfigurationChangedEvent {
}
}
}
}
export
class
ViewContentSizeChangedEvent
implements
IContentSizeChangedEvent
{
public
readonly
type
=
ViewEventType
.
ViewContentSizeChanged
;
public
readonly
contentWidth
:
number
;
public
readonly
contentHeight
:
number
;
public
readonly
contentWidthChanged
:
boolean
;
public
readonly
contentHeightChanged
:
boolean
;
constructor
(
source
:
IContentSizeChangedEvent
)
{
this
.
contentWidth
=
source
.
contentWidth
;
this
.
contentHeight
=
source
.
contentHeight
;
this
.
contentWidthChanged
=
source
.
contentWidthChanged
;
this
.
contentHeightChanged
=
source
.
contentHeightChanged
;
}
}
export
class
ViewCursorStateChangedEvent
{
export
class
ViewCursorStateChangedEvent
{
public
readonly
type
=
ViewEventType
.
ViewCursorStateChanged
;
public
readonly
type
=
ViewEventType
.
ViewCursorStateChanged
;
...
@@ -308,7 +286,6 @@ export class ViewZonesChangedEvent {
...
@@ -308,7 +286,6 @@ export class ViewZonesChangedEvent {
export
type
ViewEvent
=
(
export
type
ViewEvent
=
(
ViewConfigurationChangedEvent
ViewConfigurationChangedEvent
|
ViewContentSizeChangedEvent
|
ViewCursorStateChangedEvent
|
ViewCursorStateChangedEvent
|
ViewDecorationsChangedEvent
|
ViewDecorationsChangedEvent
|
ViewFlushedEvent
|
ViewFlushedEvent
...
@@ -326,49 +303,6 @@ export type ViewEvent = (
...
@@ -326,49 +303,6 @@ export type ViewEvent = (
|
ViewZonesChangedEvent
|
ViewZonesChangedEvent
);
);
export
interface
IViewEventListener
{
(
events
:
ViewEvent
[]):
void
;
}
export
class
ViewEventEmitter
extends
Disposable
{
private
_collector
:
ViewEventsCollector
|
null
;
private
_collectorCnt
:
number
;
constructor
()
{
super
();
this
.
_collector
=
null
;
this
.
_collectorCnt
=
0
;
}
protected
_beginEmitViewEvents
():
ViewEventsCollector
{
this
.
_collectorCnt
++
;
if
(
this
.
_collectorCnt
===
1
)
{
this
.
_collector
=
new
ViewEventsCollector
();
}
return
this
.
_collector
!
;
}
protected
_endEmitViewEvents
(
eventDispatcher
:
ViewModelEventDispatcher
):
void
{
this
.
_collectorCnt
--
;
if
(
this
.
_collectorCnt
===
0
)
{
const
events
=
this
.
_collector
!
.
finalize
();
this
.
_collector
=
null
;
if
(
events
.
length
>
0
)
{
eventDispatcher
.
emitMany
(
events
);
}
}
}
protected
_emitSingleViewEvent
(
eventDispatcher
:
ViewModelEventDispatcher
,
event
:
ViewEvent
):
void
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
eventsCollector
.
emit
(
event
);
}
finally
{
this
.
_endEmitViewEvents
(
eventDispatcher
);
}
}
}
export
class
ViewEventsCollector
{
export
class
ViewEventsCollector
{
private
_events
:
ViewEvent
[];
private
_events
:
ViewEvent
[];
...
@@ -388,5 +322,4 @@ export class ViewEventsCollector {
...
@@ -388,5 +322,4 @@ export class ViewEventsCollector {
this
.
_events
=
[];
this
.
_events
=
[];
return
result
;
return
result
;
}
}
}
}
src/vs/editor/common/viewLayout/viewLayout.ts
浏览文件 @
1620c36f
...
@@ -7,10 +7,11 @@ import { Event, Emitter } from 'vs/base/common/event';
...
@@ -7,10 +7,11 @@ import { Event, Emitter } from 'vs/base/common/event';
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IScrollPosition
,
ScrollEvent
,
Scrollable
,
ScrollbarVisibility
,
INewScrollPosition
}
from
'
vs/base/common/scrollable
'
;
import
{
IScrollPosition
,
ScrollEvent
,
Scrollable
,
ScrollbarVisibility
,
INewScrollPosition
}
from
'
vs/base/common/scrollable
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IConfiguration
,
IContentSizeChangedEvent
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IConfiguration
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
LinesLayout
,
IEditorWhitespace
,
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
LinesLayout
,
IEditorWhitespace
,
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
IPartialViewLinesViewportData
}
from
'
vs/editor/common/viewLayout/viewLinesViewportData
'
;
import
{
IPartialViewLinesViewportData
}
from
'
vs/editor/common/viewLayout/viewLinesViewportData
'
;
import
{
IViewLayout
,
IViewWhitespaceViewportData
,
Viewport
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
IViewLayout
,
IViewWhitespaceViewportData
,
Viewport
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
ContentSizeChangedEvent
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
const
SMOOTH_SCROLLING_TIME
=
125
;
const
SMOOTH_SCROLLING_TIME
=
125
;
...
@@ -75,8 +76,8 @@ class EditorScrollable extends Disposable {
...
@@ -75,8 +76,8 @@ class EditorScrollable extends Disposable {
public
readonly
onDidScroll
:
Event
<
ScrollEvent
>
;
public
readonly
onDidScroll
:
Event
<
ScrollEvent
>
;
private
readonly
_onDidContentSizeChange
=
this
.
_register
(
new
Emitter
<
I
ContentSizeChangedEvent
>
());
private
readonly
_onDidContentSizeChange
=
this
.
_register
(
new
Emitter
<
ContentSizeChangedEvent
>
());
public
readonly
onDidContentSizeChange
:
Event
<
I
ContentSizeChangedEvent
>
=
this
.
_onDidContentSizeChange
.
event
;
public
readonly
onDidContentSizeChange
:
Event
<
ContentSizeChangedEvent
>
=
this
.
_onDidContentSizeChange
.
event
;
constructor
(
smoothScrollDuration
:
number
,
scheduleAtNextAnimationFrame
:
(
callback
:
()
=>
void
)
=>
IDisposable
)
{
constructor
(
smoothScrollDuration
:
number
,
scheduleAtNextAnimationFrame
:
(
callback
:
()
=>
void
)
=>
IDisposable
)
{
super
();
super
();
...
@@ -119,13 +120,10 @@ class EditorScrollable extends Disposable {
...
@@ -119,13 +120,10 @@ class EditorScrollable extends Disposable {
const
contentWidthChanged
=
(
oldDimensions
.
contentWidth
!==
dimensions
.
contentWidth
);
const
contentWidthChanged
=
(
oldDimensions
.
contentWidth
!==
dimensions
.
contentWidth
);
const
contentHeightChanged
=
(
oldDimensions
.
contentHeight
!==
dimensions
.
contentHeight
);
const
contentHeightChanged
=
(
oldDimensions
.
contentHeight
!==
dimensions
.
contentHeight
);
if
(
contentWidthChanged
||
contentHeightChanged
)
{
if
(
contentWidthChanged
||
contentHeightChanged
)
{
this
.
_onDidContentSizeChange
.
fire
({
this
.
_onDidContentSizeChange
.
fire
(
new
ContentSizeChangedEvent
(
contentWidth
:
dimensions
.
contentWidth
,
oldDimensions
.
contentWidth
,
oldDimensions
.
contentHeight
,
contentHeight
:
dimensions
.
contentHeight
,
dimensions
.
contentWidth
,
dimensions
.
contentHeight
));
contentWidthChanged
:
contentWidthChanged
,
contentHeightChanged
:
contentHeightChanged
});
}
}
}
}
...
@@ -153,7 +151,7 @@ export class ViewLayout extends Disposable implements IViewLayout {
...
@@ -153,7 +151,7 @@ export class ViewLayout extends Disposable implements IViewLayout {
private
readonly
_scrollable
:
EditorScrollable
;
private
readonly
_scrollable
:
EditorScrollable
;
public
readonly
onDidScroll
:
Event
<
ScrollEvent
>
;
public
readonly
onDidScroll
:
Event
<
ScrollEvent
>
;
public
readonly
onDidContentSizeChange
:
Event
<
I
ContentSizeChangedEvent
>
;
public
readonly
onDidContentSizeChange
:
Event
<
ContentSizeChangedEvent
>
;
constructor
(
configuration
:
IConfiguration
,
lineCount
:
number
,
scheduleAtNextAnimationFrame
:
(
callback
:
()
=>
void
)
=>
IDisposable
)
{
constructor
(
configuration
:
IConfiguration
,
lineCount
:
number
,
scheduleAtNextAnimationFrame
:
(
callback
:
()
=>
void
)
=>
IDisposable
)
{
super
();
super
();
...
...
src/vs/editor/common/viewModel/viewEventHandler.ts
浏览文件 @
1620c36f
...
@@ -36,9 +36,7 @@ export class ViewEventHandler extends Disposable {
...
@@ -36,9 +36,7 @@ export class ViewEventHandler extends Disposable {
public
onConfigurationChanged
(
e
:
viewEvents
.
ViewConfigurationChangedEvent
):
boolean
{
public
onConfigurationChanged
(
e
:
viewEvents
.
ViewConfigurationChangedEvent
):
boolean
{
return
false
;
return
false
;
}
}
public
onContentSizeChanged
(
e
:
viewEvents
.
ViewContentSizeChangedEvent
):
boolean
{
return
false
;
}
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
return
false
;
return
false
;
}
}
...
@@ -102,12 +100,6 @@ export class ViewEventHandler extends Disposable {
...
@@ -102,12 +100,6 @@ export class ViewEventHandler extends Disposable {
}
}
break
;
break
;
case
viewEvents
.
ViewEventType
.
ViewContentSizeChanged
:
if
(
this
.
onContentSizeChanged
(
e
))
{
shouldRender
=
true
;
}
break
;
case
viewEvents
.
ViewEventType
.
ViewCursorStateChanged
:
case
viewEvents
.
ViewEventType
.
ViewCursorStateChanged
:
if
(
this
.
onCursorStateChanged
(
e
))
{
if
(
this
.
onCursorStateChanged
(
e
))
{
shouldRender
=
true
;
shouldRender
=
true
;
...
...
src/vs/editor/common/viewModel/viewModelEventDispatcher.ts
浏览文件 @
1620c36f
...
@@ -4,21 +4,58 @@
...
@@ -4,21 +4,58 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
import
{
ViewEvent
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ViewEvent
,
ViewEventsCollector
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IContentSizeChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IContentSizeChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
ViewModelEventDispatcher
{
export
class
ViewModelEventDispatcher
extends
Disposable
{
private
readonly
_onEvent
=
this
.
_register
(
new
Emitter
<
OutgoingViewModelEvent
>
());
public
readonly
onEvent
=
this
.
_onEvent
.
event
;
private
readonly
_eventHandlers
:
ViewEventHandler
[];
private
readonly
_eventHandlers
:
ViewEventHandler
[];
private
_viewEventQueue
:
ViewEvent
[]
|
null
;
private
_viewEventQueue
:
ViewEvent
[]
|
null
;
private
_isConsumingViewEventQueue
:
boolean
;
private
_isConsumingViewEventQueue
:
boolean
;
// private _outgoingContentSizeChangedEvent: OutgoingContentSizeChangedEvent | null;
private
_collector
:
ViewEventsCollector
|
null
;
private
_collectorCnt
:
number
;
private
_outgoingEvents
:
OutgoingViewModelEvent
[];
constructor
()
{
constructor
()
{
super
();
this
.
_eventHandlers
=
[];
this
.
_eventHandlers
=
[];
this
.
_viewEventQueue
=
null
;
this
.
_viewEventQueue
=
null
;
this
.
_isConsumingViewEventQueue
=
false
;
this
.
_isConsumingViewEventQueue
=
false
;
// this._outgoingContentSizeChangedEvent = null;
this
.
_collector
=
null
;
this
.
_collectorCnt
=
0
;
this
.
_outgoingEvents
=
[];
}
public
emitOutgoingEvent
(
e
:
OutgoingViewModelEvent
):
void
{
this
.
_addOutgoingEvent
(
e
);
this
.
_emitOugoingEvents
();
}
private
_addOutgoingEvent
(
e
:
OutgoingViewModelEvent
):
void
{
for
(
let
i
=
0
,
len
=
this
.
_outgoingEvents
.
length
;
i
<
len
;
i
++
)
{
if
(
this
.
_outgoingEvents
[
i
].
kind
===
e
.
kind
)
{
this
.
_outgoingEvents
[
i
]
=
this
.
_outgoingEvents
[
i
].
merge
(
e
);
return
;
}
}
// not merged
this
.
_outgoingEvents
.
push
(
e
);
}
private
_emitOugoingEvents
():
void
{
while
(
this
.
_outgoingEvents
.
length
>
0
)
{
if
(
this
.
_collector
||
this
.
_isConsumingViewEventQueue
)
{
// right now collecting or emitting view events, so let's postpone emitting
return
;
}
const
event
=
this
.
_outgoingEvents
.
shift
()
!
;
this
.
_onEvent
.
fire
(
event
);
}
}
}
public
addViewEventHandler
(
eventHandler
:
ViewEventHandler
):
void
{
public
addViewEventHandler
(
eventHandler
:
ViewEventHandler
):
void
{
...
@@ -39,7 +76,36 @@ export class ViewModelEventDispatcher {
...
@@ -39,7 +76,36 @@ export class ViewModelEventDispatcher {
}
}
}
}
public
emitMany
(
events
:
ViewEvent
[]):
void
{
public
beginEmitViewEvents
():
ViewEventsCollector
{
this
.
_collectorCnt
++
;
if
(
this
.
_collectorCnt
===
1
)
{
this
.
_collector
=
new
ViewEventsCollector
();
}
return
this
.
_collector
!
;
}
public
endEmitViewEvents
():
void
{
this
.
_collectorCnt
--
;
if
(
this
.
_collectorCnt
===
0
)
{
const
events
=
this
.
_collector
!
.
finalize
();
this
.
_collector
=
null
;
if
(
events
.
length
>
0
)
{
this
.
_emitMany
(
events
);
}
}
this
.
_emitOugoingEvents
();
}
public
emitSingleViewEvent
(
event
:
ViewEvent
):
void
{
try
{
const
eventsCollector
=
this
.
beginEmitViewEvents
();
eventsCollector
.
emit
(
event
);
}
finally
{
this
.
endEmitViewEvents
();
}
}
private
_emitMany
(
events
:
ViewEvent
[]):
void
{
if
(
this
.
_viewEventQueue
)
{
if
(
this
.
_viewEventQueue
)
{
this
.
_viewEventQueue
=
this
.
_viewEventQueue
.
concat
(
events
);
this
.
_viewEventQueue
=
this
.
_viewEventQueue
.
concat
(
events
);
}
else
{
}
else
{
...
@@ -75,7 +141,13 @@ export class ViewModelEventDispatcher {
...
@@ -75,7 +141,13 @@ export class ViewModelEventDispatcher {
}
}
}
}
export
class
OutgoingContentSizeChangedEvent
implements
IContentSizeChangedEvent
{
export
const
enum
OutgoingViewModelEventKind
{
ContentSizeChanged
,
}
export
class
ContentSizeChangedEvent
implements
IContentSizeChangedEvent
{
public
readonly
kind
=
OutgoingViewModelEventKind
.
ContentSizeChanged
;
private
readonly
_oldContentWidth
:
number
;
private
readonly
_oldContentWidth
:
number
;
private
readonly
_oldContentHeight
:
number
;
private
readonly
_oldContentHeight
:
number
;
...
@@ -93,4 +165,10 @@ export class OutgoingContentSizeChangedEvent implements IContentSizeChangedEvent
...
@@ -93,4 +165,10 @@ export class OutgoingContentSizeChangedEvent implements IContentSizeChangedEvent
this
.
contentWidthChanged
=
(
this
.
_oldContentWidth
!==
this
.
contentWidth
);
this
.
contentWidthChanged
=
(
this
.
_oldContentWidth
!==
this
.
contentWidth
);
this
.
contentHeightChanged
=
(
this
.
_oldContentHeight
!==
this
.
contentHeight
);
this
.
contentHeightChanged
=
(
this
.
_oldContentHeight
!==
this
.
contentHeight
);
}
}
public
merge
(
other
:
ContentSizeChangedEvent
):
ContentSizeChangedEvent
{
return
new
ContentSizeChangedEvent
(
this
.
_oldContentWidth
,
this
.
_oldContentHeight
,
other
.
contentWidth
,
other
.
contentHeight
);
}
}
}
export
type
OutgoingViewModelEvent
=
ContentSizeChangedEvent
;
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
1620c36f
...
@@ -4,7 +4,8 @@
...
@@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
ConfigurationChangedEvent
,
EDITOR_FONT_DEFAULTS
,
EditorOption
,
filterValidationDecorations
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
ConfigurationChangedEvent
,
EDITOR_FONT_DEFAULTS
,
EditorOption
,
filterValidationDecorations
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IPosition
,
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IPosition
,
Position
}
from
'
vs/editor/common/core/position
'
;
...
@@ -29,17 +30,18 @@ import { Cursor } from 'vs/editor/common/controller/cursor';
...
@@ -29,17 +30,18 @@ import { Cursor } from 'vs/editor/common/controller/cursor';
import
{
PartialCursorState
,
CursorState
,
IColumnSelectData
,
EditOperationType
,
CursorConfiguration
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
PartialCursorState
,
CursorState
,
IColumnSelectData
,
EditOperationType
,
CursorConfiguration
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
ViewModelEventDispatcher
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
import
{
ViewModelEventDispatcher
,
OutgoingViewModelEvent
}
from
'
vs/editor/common/viewModel/viewModelEventDispatcher
'
;
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
const
USE_IDENTITY_LINES_COLLECTION
=
true
;
const
USE_IDENTITY_LINES_COLLECTION
=
true
;
export
class
ViewModel
extends
viewEvents
.
ViewEventEmitter
implements
IViewModel
{
export
class
ViewModel
extends
Disposable
implements
IViewModel
{
private
readonly
editorId
:
number
;
private
readonly
editorId
:
number
;
private
readonly
configuration
:
IConfiguration
;
private
readonly
configuration
:
IConfiguration
;
public
readonly
model
:
ITextModel
;
public
readonly
model
:
ITextModel
;
private
readonly
_eventDispatcher
:
ViewModelEventDispatcher
;
private
readonly
_eventDispatcher
:
ViewModelEventDispatcher
;
public
readonly
onEvent
:
Event
<
OutgoingViewModelEvent
>
;
public
cursorConfig
:
CursorConfiguration
;
public
cursorConfig
:
CursorConfiguration
;
private
readonly
_tokenizeViewportSoon
:
RunOnceScheduler
;
private
readonly
_tokenizeViewportSoon
:
RunOnceScheduler
;
private
readonly
_updateConfigurationViewLineCount
:
RunOnceScheduler
;
private
readonly
_updateConfigurationViewLineCount
:
RunOnceScheduler
;
...
@@ -67,6 +69,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -67,6 +69,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
configuration
=
configuration
;
this
.
configuration
=
configuration
;
this
.
model
=
model
;
this
.
model
=
model
;
this
.
_eventDispatcher
=
new
ViewModelEventDispatcher
();
this
.
_eventDispatcher
=
new
ViewModelEventDispatcher
();
this
.
onEvent
=
this
.
_eventDispatcher
.
onEvent
;
this
.
cursorConfig
=
new
CursorConfiguration
(
this
.
model
.
getLanguageIdentifier
(),
this
.
model
.
getOptions
(),
this
.
configuration
);
this
.
cursorConfig
=
new
CursorConfiguration
(
this
.
model
.
getLanguageIdentifier
(),
this
.
model
.
getOptions
(),
this
.
configuration
);
this
.
_tokenizeViewportSoon
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
tokenizeViewport
(),
50
));
this
.
_tokenizeViewportSoon
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
tokenizeViewport
(),
50
));
this
.
_updateConfigurationViewLineCount
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
_updateConfigurationViewLineCountNow
(),
0
));
this
.
_updateConfigurationViewLineCount
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
_updateConfigurationViewLineCountNow
(),
0
));
...
@@ -108,11 +111,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -108,11 +111,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
if
(
e
.
scrollTopChanged
)
{
if
(
e
.
scrollTopChanged
)
{
this
.
_tokenizeViewportSoon
.
schedule
();
this
.
_tokenizeViewportSoon
.
schedule
();
}
}
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewScrollChangedEvent
(
e
));
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewScrollChangedEvent
(
e
));
}));
}));
this
.
_register
(
this
.
viewLayout
.
onDidContentSizeChange
((
e
)
=>
{
this
.
_register
(
this
.
viewLayout
.
onDidContentSizeChange
((
e
)
=>
{
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewContentSizeChangedEvent
(
e
)
);
this
.
_e
ventDispatcher
.
emitOutgoingEvent
(
e
);
}));
}));
this
.
decorations
=
new
ViewModelDecorations
(
this
.
editorId
,
this
.
model
,
this
.
configuration
,
this
.
lines
,
this
.
coordinatesConverter
);
this
.
decorations
=
new
ViewModelDecorations
(
this
.
editorId
,
this
.
model
,
this
.
configuration
,
this
.
lines
,
this
.
coordinatesConverter
);
...
@@ -121,15 +124,15 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -121,15 +124,15 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
_register
(
this
.
configuration
.
onDidChange
((
e
)
=>
{
this
.
_register
(
this
.
configuration
.
onDidChange
((
e
)
=>
{
try
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
const
eventsCollector
=
this
.
_
eventDispatcher
.
beginEmitViewEvents
();
this
.
_onConfigurationChanged
(
eventsCollector
,
e
);
this
.
_onConfigurationChanged
(
eventsCollector
,
e
);
}
finally
{
}
finally
{
this
.
_e
ndEmitViewEvents
(
this
.
_eventDispatcher
);
this
.
_e
ventDispatcher
.
endEmitViewEvents
(
);
}
}
}));
}));
this
.
_register
(
MinimapTokensColorTracker
.
getInstance
().
onDidChange
(()
=>
{
this
.
_register
(
MinimapTokensColorTracker
.
getInstance
().
onDidChange
(()
=>
{
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewTokensColorsChangedEvent
());
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewTokensColorsChangedEvent
());
}));
}));
this
.
_updateConfigurationViewLineCountNow
();
this
.
_updateConfigurationViewLineCountNow
();
...
@@ -143,6 +146,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -143,6 +146,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
lines
.
dispose
();
this
.
lines
.
dispose
();
this
.
invalidateMinimapColorCache
();
this
.
invalidateMinimapColorCache
();
this
.
viewportStartLineTrackedRange
=
this
.
model
.
_setTrackedRange
(
this
.
viewportStartLineTrackedRange
,
null
,
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
);
this
.
viewportStartLineTrackedRange
=
this
.
model
.
_setTrackedRange
(
this
.
viewportStartLineTrackedRange
,
null
,
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
);
this
.
_eventDispatcher
.
dispose
();
}
}
public
addViewEventHandler
(
eventHandler
:
ViewEventHandler
):
void
{
public
addViewEventHandler
(
eventHandler
:
ViewEventHandler
):
void
{
...
@@ -167,11 +171,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -167,11 +171,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
public
setHasFocus
(
hasFocus
:
boolean
):
void
{
public
setHasFocus
(
hasFocus
:
boolean
):
void
{
this
.
hasFocus
=
hasFocus
;
this
.
hasFocus
=
hasFocus
;
this
.
cursor
.
setHasFocus
(
hasFocus
);
this
.
cursor
.
setHasFocus
(
hasFocus
);
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewFocusChangedEvent
(
hasFocus
));
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewFocusChangedEvent
(
hasFocus
));
}
}
public
onDidColorThemeChange
():
void
{
public
onDidColorThemeChange
():
void
{
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewThemeChangedEvent
());
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewThemeChangedEvent
());
}
}
private
_onConfigurationChanged
(
eventsCollector
:
viewEvents
.
ViewEventsCollector
,
e
:
ConfigurationChangedEvent
):
void
{
private
_onConfigurationChanged
(
eventsCollector
:
viewEvents
.
ViewEventsCollector
,
e
:
ConfigurationChangedEvent
):
void
{
...
@@ -231,7 +235,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -231,7 +235,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
_register
(
this
.
model
.
onDidChangeRawContentFast
((
e
)
=>
{
this
.
_register
(
this
.
model
.
onDidChangeRawContentFast
((
e
)
=>
{
try
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
const
eventsCollector
=
this
.
_
eventDispatcher
.
beginEmitViewEvents
();
let
hadOtherModelChange
=
false
;
let
hadOtherModelChange
=
false
;
let
hadModelLineChangeThatChangedLineMapping
=
false
;
let
hadModelLineChangeThatChangedLineMapping
=
false
;
...
@@ -325,7 +329,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -325,7 +329,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
decorations
.
onLineMappingChanged
();
this
.
decorations
.
onLineMappingChanged
();
}
}
}
finally
{
}
finally
{
this
.
_e
ndEmitViewEvents
(
this
.
_eventDispatcher
);
this
.
_e
ventDispatcher
.
endEmitViewEvents
(
);
}
}
// Update the configuration and reset the centered view line
// Update the configuration and reset the centered view line
...
@@ -344,10 +348,10 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -344,10 +348,10 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
}
}
try
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
const
eventsCollector
=
this
.
_
eventDispatcher
.
beginEmitViewEvents
();
this
.
cursor
.
onModelContentChanged
(
eventsCollector
,
e
);
this
.
cursor
.
onModelContentChanged
(
eventsCollector
,
e
);
}
finally
{
}
finally
{
this
.
_e
ndEmitViewEvents
(
this
.
_eventDispatcher
);
this
.
_e
ventDispatcher
.
endEmitViewEvents
(
);
}
}
}));
}));
...
@@ -362,7 +366,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -362,7 +366,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
toLineNumber
:
viewEndLineNumber
toLineNumber
:
viewEndLineNumber
};
};
}
}
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewTokensChangedEvent
(
viewRanges
));
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewTokensChangedEvent
(
viewRanges
));
if
(
e
.
tokenizationSupportChanged
)
{
if
(
e
.
tokenizationSupportChanged
)
{
this
.
_tokenizeViewportSoon
.
schedule
();
this
.
_tokenizeViewportSoon
.
schedule
();
...
@@ -370,7 +374,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -370,7 +374,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
}));
}));
this
.
_register
(
this
.
model
.
onDidChangeLanguageConfiguration
((
e
)
=>
{
this
.
_register
(
this
.
model
.
onDidChangeLanguageConfiguration
((
e
)
=>
{
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewLanguageConfigurationEvent
());
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewLanguageConfigurationEvent
());
this
.
cursorConfig
=
new
CursorConfiguration
(
this
.
model
.
getLanguageIdentifier
(),
this
.
model
.
getOptions
(),
this
.
configuration
);
this
.
cursorConfig
=
new
CursorConfiguration
(
this
.
model
.
getLanguageIdentifier
(),
this
.
model
.
getOptions
(),
this
.
configuration
);
this
.
cursor
.
updateConfiguration
(
this
.
cursorConfig
);
this
.
cursor
.
updateConfiguration
(
this
.
cursorConfig
);
}));
}));
...
@@ -384,7 +388,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -384,7 +388,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
// A tab size change causes a line mapping changed event => all view parts will repaint OK, no further event needed here
// A tab size change causes a line mapping changed event => all view parts will repaint OK, no further event needed here
if
(
this
.
lines
.
setTabSize
(
this
.
model
.
getOptions
().
tabSize
))
{
if
(
this
.
lines
.
setTabSize
(
this
.
model
.
getOptions
().
tabSize
))
{
try
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
const
eventsCollector
=
this
.
_
eventDispatcher
.
beginEmitViewEvents
();
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
...
@@ -392,7 +396,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -392,7 +396,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
decorations
.
onLineMappingChanged
();
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
}
finally
{
}
finally
{
this
.
_e
ndEmitViewEvents
(
this
.
_eventDispatcher
);
this
.
_e
ventDispatcher
.
endEmitViewEvents
(
);
}
}
this
.
_updateConfigurationViewLineCount
.
schedule
();
this
.
_updateConfigurationViewLineCount
.
schedule
();
}
}
...
@@ -403,13 +407,13 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -403,13 +407,13 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
_register
(
this
.
model
.
onDidChangeDecorations
((
e
)
=>
{
this
.
_register
(
this
.
model
.
onDidChangeDecorations
((
e
)
=>
{
this
.
decorations
.
onModelDecorationsChanged
();
this
.
decorations
.
onModelDecorationsChanged
();
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewDecorationsChangedEvent
(
e
));
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
e
));
}));
}));
}
}
public
setHiddenAreas
(
ranges
:
Range
[]):
void
{
public
setHiddenAreas
(
ranges
:
Range
[]):
void
{
try
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
const
eventsCollector
=
this
.
_
eventDispatcher
.
beginEmitViewEvents
();
let
lineMappingChanged
=
this
.
lines
.
setHiddenAreas
(
ranges
);
let
lineMappingChanged
=
this
.
lines
.
setHiddenAreas
(
ranges
);
if
(
lineMappingChanged
)
{
if
(
lineMappingChanged
)
{
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
...
@@ -421,7 +425,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -421,7 +425,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
viewLayout
.
onHeightMaybeChanged
();
this
.
viewLayout
.
onHeightMaybeChanged
();
}
}
}
finally
{
}
finally
{
this
.
_e
ndEmitViewEvents
(
this
.
_eventDispatcher
);
this
.
_e
ventDispatcher
.
endEmitViewEvents
(
);
}
}
this
.
_updateConfigurationViewLineCount
.
schedule
();
this
.
_updateConfigurationViewLineCount
.
schedule
();
}
}
...
@@ -970,7 +974,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -970,7 +974,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
public
changeWhitespace
(
callback
:
(
accessor
:
IWhitespaceChangeAccessor
)
=>
void
):
void
{
public
changeWhitespace
(
callback
:
(
accessor
:
IWhitespaceChangeAccessor
)
=>
void
):
void
{
const
hadAChange
=
this
.
viewLayout
.
changeWhitespace
(
callback
);
const
hadAChange
=
this
.
viewLayout
.
changeWhitespace
(
callback
);
if
(
hadAChange
)
{
if
(
hadAChange
)
{
this
.
_e
mitSingleViewEvent
(
this
.
_eventDispatcher
,
new
viewEvents
.
ViewZonesChangedEvent
());
this
.
_e
ventDispatcher
.
emitSingleViewEvent
(
new
viewEvents
.
ViewZonesChangedEvent
());
}
}
}
}
public
setMaxLineWidth
(
maxLineWidth
:
number
):
void
{
public
setMaxLineWidth
(
maxLineWidth
:
number
):
void
{
...
@@ -980,10 +984,10 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
...
@@ -980,10 +984,10 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
private
_withViewEventsCollector
(
callback
:
(
eventsCollector
:
viewEvents
.
ViewEventsCollector
)
=>
void
):
void
{
private
_withViewEventsCollector
(
callback
:
(
eventsCollector
:
viewEvents
.
ViewEventsCollector
)
=>
void
):
void
{
try
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
const
eventsCollector
=
this
.
_
eventDispatcher
.
beginEmitViewEvents
();
callback
(
eventsCollector
);
callback
(
eventsCollector
);
}
finally
{
}
finally
{
this
.
_e
ndEmitViewEvents
(
this
.
_eventDispatcher
);
this
.
_e
ventDispatcher
.
endEmitViewEvents
(
);
}
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录