Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7d098ad4
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,发现更多精彩内容 >>
提交
7d098ad4
编写于
5月 21, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge view cursor position & selection changed events into a single event (#26730)
上级
0e3d227c
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
81 addition
and
110 deletion
+81
-110
src/vs/editor/browser/controller/mouseHandler.ts
src/vs/editor/browser/controller/mouseHandler.ts
+4
-4
src/vs/editor/browser/controller/textAreaHandler.ts
src/vs/editor/browser/controller/textAreaHandler.ts
+2
-2
src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts
...er/viewParts/currentLineHighlight/currentLineHighlight.ts
+13
-10
src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts
.../currentLineMarginHighlight/currentLineMarginHighlight.ts
+7
-3
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
+3
-2
src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts
...owser/viewParts/overviewRuler/decorationsOverviewRuler.ts
+5
-3
src/vs/editor/browser/viewParts/selections/selections.ts
src/vs/editor/browser/viewParts/selections/selections.ts
+2
-3
src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts
src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts
+19
-12
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+2
-11
src/vs/editor/common/view/viewEvents.ts
src/vs/editor/common/view/viewEvents.ts
+21
-48
src/vs/editor/common/viewModel/viewEventHandler.ts
src/vs/editor/common/viewModel/viewEventHandler.ts
+3
-12
未找到文件。
src/vs/editor/browser/controller/mouseHandler.ts
浏览文件 @
7d098ad4
...
...
@@ -134,8 +134,8 @@ export class MouseHandler extends ViewEventHandler {
}
// --- begin event handlers
public
onCursorS
electionChanged
(
e
:
viewEvents
.
ViewCursorSelection
ChangedEvent
):
boolean
{
this
.
_mouseDownOperation
.
onCursorS
election
Changed
(
e
);
public
onCursorS
tateChanged
(
e
:
viewEvents
.
ViewCursorState
ChangedEvent
):
boolean
{
this
.
_mouseDownOperation
.
onCursorS
tate
Changed
(
e
);
return
false
;
}
private
_isFocused
=
false
;
...
...
@@ -411,8 +411,8 @@ class MouseDownOperation extends Disposable {
},
10
);
}
public
onCursorS
electionChanged
(
e
:
viewEvents
.
ViewCursorSelection
ChangedEvent
):
void
{
this
.
_currentSelection
=
e
.
selection
;
public
onCursorS
tateChanged
(
e
:
viewEvents
.
ViewCursorState
ChangedEvent
):
void
{
this
.
_currentSelection
=
e
.
selection
s
[
0
]
;
}
private
_getPositionOutsideEditor
(
e
:
EditorMouseEvent
):
MouseTarget
{
...
...
src/vs/editor/browser/controller/textAreaHandler.ts
浏览文件 @
7d098ad4
...
...
@@ -292,8 +292,8 @@ export class TextAreaHandler extends ViewPart {
return
true
;
}
public
onCursorS
electionChanged
(
e
:
viewEvents
.
ViewCursorSelection
ChangedEvent
):
boolean
{
this
.
_selections
=
[
e
.
selection
].
concat
(
e
.
secondarySelections
);
public
onCursorS
tateChanged
(
e
:
viewEvents
.
ViewCursorState
ChangedEvent
):
boolean
{
this
.
_selections
=
e
.
selections
.
slice
(
0
);
return
true
;
}
public
onDecorationsChanged
(
e
:
viewEvents
.
ViewDecorationsChangedEvent
):
boolean
{
...
...
src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts
浏览文件 @
7d098ad4
...
...
@@ -63,25 +63,28 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
}
return
true
;
}
public
onCursor
PositionChanged
(
e
:
viewEvents
.
ViewCursorPosition
ChangedEvent
):
boolean
{
public
onCursor
StateChanged
(
e
:
viewEvents
.
ViewCursorState
ChangedEvent
):
boolean
{
let
hasChanged
=
false
;
if
(
this
.
_primaryCursorIsInEditableRange
!==
e
.
isInEditableRange
)
{
this
.
_primaryCursorIsInEditableRange
=
e
.
isInEditableRange
;
hasChanged
=
true
;
}
if
(
this
.
_primaryCursorLineNumber
!==
e
.
position
.
lineNumber
)
{
this
.
_primaryCursorLineNumber
=
e
.
position
.
lineNumber
;
const
primaryCursorLineNumber
=
e
.
selections
[
0
].
positionLineNumber
;
if
(
this
.
_primaryCursorLineNumber
!==
primaryCursorLineNumber
)
{
this
.
_primaryCursorLineNumber
=
primaryCursorLineNumber
;
hasChanged
=
true
;
}
return
hasChanged
;
}
public
onCursorSelectionChanged
(
e
:
viewEvents
.
ViewCursorSelectionChangedEvent
):
boolean
{
let
isEmpty
=
e
.
selection
.
isEmpty
();
if
(
this
.
_selectionIsEmpty
!==
isEmpty
)
{
this
.
_selectionIsEmpty
=
isEmpty
;
const
selectionIsEmpty
=
e
.
selections
[
0
].
isEmpty
();
if
(
this
.
_selectionIsEmpty
!==
selectionIsEmpty
)
{
this
.
_selectionIsEmpty
=
selectionIsEmpty
;
hasChanged
=
true
;
return
true
;
}
return
false
;
return
hasChanged
;
}
public
onFlushed
(
e
:
viewEvents
.
ViewFlushedEvent
):
boolean
{
return
true
;
...
...
src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts
浏览文件 @
7d098ad4
...
...
@@ -54,16 +54,20 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
}
return
true
;
}
public
onCursor
PositionChanged
(
e
:
viewEvents
.
ViewCursorPosition
ChangedEvent
):
boolean
{
public
onCursor
StateChanged
(
e
:
viewEvents
.
ViewCursorState
ChangedEvent
):
boolean
{
let
hasChanged
=
false
;
if
(
this
.
_primaryCursorIsInEditableRange
!==
e
.
isInEditableRange
)
{
this
.
_primaryCursorIsInEditableRange
=
e
.
isInEditableRange
;
hasChanged
=
true
;
}
if
(
this
.
_primaryCursorLineNumber
!==
e
.
position
.
lineNumber
)
{
this
.
_primaryCursorLineNumber
=
e
.
position
.
lineNumber
;
const
primaryCursorLineNumber
=
e
.
selections
[
0
].
positionLineNumber
;
if
(
this
.
_primaryCursorLineNumber
!==
primaryCursorLineNumber
)
{
this
.
_primaryCursorLineNumber
=
primaryCursorLineNumber
;
hasChanged
=
true
;
}
return
hasChanged
;
}
public
onFlushed
(
e
:
viewEvents
.
ViewFlushedEvent
):
boolean
{
...
...
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
浏览文件 @
7d098ad4
...
...
@@ -65,8 +65,9 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
this
.
_readConfig
();
return
true
;
}
public
onCursorPositionChanged
(
e
:
viewEvents
.
ViewCursorPositionChangedEvent
):
boolean
{
this
.
_lastCursorModelPosition
=
this
.
_context
.
model
.
coordinatesConverter
.
convertViewPositionToModelPosition
(
e
.
position
);
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
const
primaryViewPosition
=
e
.
selections
[
0
].
getPosition
();
this
.
_lastCursorModelPosition
=
this
.
_context
.
model
.
coordinatesConverter
.
convertViewPositionToModelPosition
(
primaryViewPosition
);
if
(
this
.
_renderRelativeLineNumbers
)
{
return
true
;
...
...
src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts
浏览文件 @
7d098ad4
...
...
@@ -122,10 +122,12 @@ export class DecorationsOverviewRuler extends ViewPart {
return
true
;
}
public
onCursor
PositionChanged
(
e
:
viewEvents
.
ViewCursorPosition
ChangedEvent
):
boolean
{
public
onCursor
StateChanged
(
e
:
viewEvents
.
ViewCursorState
ChangedEvent
):
boolean
{
this
.
_shouldUpdateCursorPosition
=
true
;
this
.
_cursorPositions
=
[
e
.
position
];
this
.
_cursorPositions
=
this
.
_cursorPositions
.
concat
(
e
.
secondaryPositions
);
this
.
_cursorPositions
=
[];
for
(
let
i
=
0
,
len
=
e
.
selections
.
length
;
i
<
len
;
i
++
)
{
this
.
_cursorPositions
[
i
]
=
e
.
selections
[
i
].
getPosition
();
}
return
true
;
}
...
...
src/vs/editor/browser/viewParts/selections/selections.ts
浏览文件 @
7d098ad4
...
...
@@ -110,9 +110,8 @@ export class SelectionsOverlay extends DynamicViewOverlay {
}
return
true
;
}
public
onCursorSelectionChanged
(
e
:
viewEvents
.
ViewCursorSelectionChangedEvent
):
boolean
{
this
.
_selections
=
[
e
.
selection
];
this
.
_selections
=
this
.
_selections
.
concat
(
e
.
secondarySelections
);
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
this
.
_selections
=
e
.
selections
.
slice
(
0
);
return
true
;
}
public
onDecorationsChanged
(
e
:
viewEvents
.
ViewDecorationsChangedEvent
):
boolean
{
...
...
src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts
浏览文件 @
7d098ad4
...
...
@@ -99,41 +99,48 @@ export class ViewCursors extends ViewPart {
}
return
true
;
}
p
ublic
onCursorPositionChanged
(
e
:
viewEvents
.
ViewCursorPositionChangedEvent
):
boolean
{
this
.
_primaryCursor
.
onCursorPositionChanged
(
e
.
position
,
e
.
isInEditableRange
);
p
rivate
_onCursorPositionChanged
(
position
:
Position
,
secondaryPositions
:
Position
[],
isInEditableRange
:
boolean
):
void
{
this
.
_primaryCursor
.
onCursorPositionChanged
(
position
,
isInEditableRange
);
this
.
_updateBlinking
();
if
(
this
.
_secondaryCursors
.
length
<
e
.
secondaryPositions
.
length
)
{
if
(
this
.
_secondaryCursors
.
length
<
secondaryPositions
.
length
)
{
// Create new cursors
let
addCnt
=
e
.
secondaryPositions
.
length
-
this
.
_secondaryCursors
.
length
;
let
addCnt
=
secondaryPositions
.
length
-
this
.
_secondaryCursors
.
length
;
for
(
let
i
=
0
;
i
<
addCnt
;
i
++
)
{
let
newCursor
=
new
ViewCursor
(
this
.
_context
,
true
);
this
.
_domNode
.
domNode
.
insertBefore
(
newCursor
.
getDomNode
().
domNode
,
this
.
_primaryCursor
.
getDomNode
().
domNode
.
nextSibling
);
this
.
_secondaryCursors
.
push
(
newCursor
);
}
}
else
if
(
this
.
_secondaryCursors
.
length
>
e
.
secondaryPositions
.
length
)
{
}
else
if
(
this
.
_secondaryCursors
.
length
>
secondaryPositions
.
length
)
{
// Remove some cursors
let
removeCnt
=
this
.
_secondaryCursors
.
length
-
e
.
secondaryPositions
.
length
;
let
removeCnt
=
this
.
_secondaryCursors
.
length
-
secondaryPositions
.
length
;
for
(
let
i
=
0
;
i
<
removeCnt
;
i
++
)
{
this
.
_domNode
.
removeChild
(
this
.
_secondaryCursors
[
0
].
getDomNode
());
this
.
_secondaryCursors
.
splice
(
0
,
1
);
}
}
for
(
let
i
=
0
;
i
<
e
.
secondaryPositions
.
length
;
i
++
)
{
this
.
_secondaryCursors
[
i
].
onCursorPositionChanged
(
e
.
secondaryPositions
[
i
],
e
.
isInEditableRange
);
for
(
let
i
=
0
;
i
<
secondaryPositions
.
length
;
i
++
)
{
this
.
_secondaryCursors
[
i
].
onCursorPositionChanged
(
secondaryPositions
[
i
],
isInEditableRange
);
}
return
true
;
}
public
onCursorSelectionChanged
(
e
:
viewEvents
.
ViewCursorSelectionChangedEvent
):
boolean
{
let
selectionIsEmpty
=
e
.
selection
.
isEmpty
();
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
let
positions
:
Position
[]
=
[];
for
(
let
i
=
0
,
len
=
e
.
selections
.
length
;
i
<
len
;
i
++
)
{
positions
[
i
]
=
e
.
selections
[
i
].
getPosition
();
}
this
.
_onCursorPositionChanged
(
positions
[
0
],
positions
.
slice
(
1
),
e
.
isInEditableRange
);
const
selectionIsEmpty
=
e
.
selections
[
0
].
isEmpty
();
if
(
this
.
_selectionIsEmpty
!==
selectionIsEmpty
)
{
this
.
_selectionIsEmpty
=
selectionIsEmpty
;
this
.
_updateDomClassName
();
}
return
false
;
return
true
;
}
public
onDecorationsChanged
(
e
:
viewEvents
.
ViewDecorationsChangedEvent
):
boolean
{
// true for inline decorations that can end up relayouting text
return
true
;
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
7d098ad4
...
...
@@ -360,29 +360,20 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
source
=
source
||
'
keyboard
'
;
const
positions
=
this
.
_cursors
.
getPositions
();
const
primaryPosition
=
positions
[
0
];
const
viewPositions
=
this
.
_cursors
.
getViewPositions
();
const
primaryViewPosition
=
viewPositions
[
0
];
const
secondaryViewPositions
=
viewPositions
.
slice
(
1
);
let
isInEditableRange
:
boolean
=
true
;
if
(
this
.
_model
.
hasEditableRange
())
{
const
editableRange
=
this
.
_model
.
getEditableRange
();
if
(
!
editableRange
.
containsPosition
(
p
rimaryPosition
))
{
if
(
!
editableRange
.
containsPosition
(
p
ositions
[
0
]
))
{
isInEditableRange
=
false
;
}
}
const
selections
=
this
.
_cursors
.
getSelections
();
const
viewSelections
=
this
.
_cursors
.
getViewSelections
();
const
primaryViewSelection
=
viewSelections
[
0
];
const
secondaryViewSelections
=
viewSelections
.
slice
(
1
);
this
.
_onDidChange
.
fire
(
new
CursorStateChangedEvent
(
selections
,
source
,
reason
));
this
.
_emit
([
new
viewEvents
.
ViewCursorPositionChangedEvent
(
primaryViewPosition
,
secondaryViewPositions
,
isInEditableRange
)]);
this
.
_emit
([
new
viewEvents
.
ViewCursorSelectionChangedEvent
(
primaryViewSelection
,
secondaryViewSelections
)]);
this
.
_emit
([
new
viewEvents
.
ViewCursorStateChangedEvent
(
viewSelections
,
isInEditableRange
)]);
}
private
_revealRange
(
revealTarget
:
RevealTarget
,
verticalType
:
viewEvents
.
VerticalRevealType
,
revealHorizontal
:
boolean
):
void
{
...
...
src/vs/editor/common/view/viewEvents.ts
浏览文件 @
7d098ad4
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ScrollEvent
}
from
'
vs/base/common/scrollable
'
;
...
...
@@ -14,21 +13,20 @@ import { IDisposable, Disposable } from "vs/base/common/lifecycle";
export
const
enum
ViewEventType
{
ViewConfigurationChanged
=
1
,
ViewCursorPositionChanged
=
2
,
ViewCursorSelectionChanged
=
3
,
ViewDecorationsChanged
=
4
,
ViewFlushed
=
5
,
ViewFocusChanged
=
6
,
ViewLineMappingChanged
=
7
,
ViewLinesChanged
=
8
,
ViewLinesDeleted
=
9
,
ViewLinesInserted
=
10
,
ViewRevealRangeRequest
=
11
,
ViewScrollChanged
=
12
,
ViewTokensChanged
=
13
,
ViewTokensColorsChanged
=
14
,
ViewZonesChanged
=
15
,
ViewThemeChanged
=
16
ViewCursorStateChanged
=
2
,
ViewDecorationsChanged
=
3
,
ViewFlushed
=
4
,
ViewFocusChanged
=
5
,
ViewLineMappingChanged
=
6
,
ViewLinesChanged
=
7
,
ViewLinesDeleted
=
8
,
ViewLinesInserted
=
9
,
ViewRevealRangeRequest
=
10
,
ViewScrollChanged
=
11
,
ViewTokensChanged
=
12
,
ViewTokensColorsChanged
=
13
,
ViewZonesChanged
=
14
,
ViewThemeChanged
=
15
}
export
class
ViewConfigurationChangedEvent
{
...
...
@@ -60,49 +58,25 @@ export class ViewConfigurationChangedEvent {
}
}
export
class
ViewCursor
Position
ChangedEvent
{
export
class
ViewCursor
State
ChangedEvent
{
public
readonly
type
=
ViewEventType
.
ViewCursor
Position
Changed
;
public
readonly
type
=
ViewEventType
.
ViewCursor
State
Changed
;
/**
*
Primary cursor's position
.
*
The primary selection is always at index 0
.
*/
public
readonly
position
:
Position
;
/**
* Secondary cursors' position.
*/
public
readonly
secondaryPositions
:
Position
[];
public
readonly
selections
:
Selection
[];
/**
* Is the primary cursor in the editable range?
*/
public
readonly
isInEditableRange
:
boolean
;
constructor
(
position
:
Position
,
secondaryPositions
:
Position
[],
isInEditableRange
:
boolean
)
{
this
.
position
=
position
;
this
.
secondaryPositions
=
secondaryPositions
;
constructor
(
selections
:
Selection
[],
isInEditableRange
:
boolean
)
{
this
.
selections
=
selections
;
this
.
isInEditableRange
=
isInEditableRange
;
}
}
export
class
ViewCursorSelectionChangedEvent
{
public
readonly
type
=
ViewEventType
.
ViewCursorSelectionChanged
;
/**
* The primary selection.
*/
public
readonly
selection
:
Selection
;
/**
* The secondary selections.
*/
public
readonly
secondarySelections
:
Selection
[];
constructor
(
selection
:
Selection
,
secondarySelections
:
Selection
[])
{
this
.
selection
=
selection
;
this
.
secondarySelections
=
secondarySelections
;
}
}
export
class
ViewDecorationsChangedEvent
{
public
readonly
type
=
ViewEventType
.
ViewDecorationsChanged
;
...
...
@@ -304,8 +278,7 @@ export class ViewZonesChangedEvent {
export
type
ViewEvent
=
(
ViewConfigurationChangedEvent
|
ViewCursorPositionChangedEvent
|
ViewCursorSelectionChangedEvent
|
ViewCursorStateChangedEvent
|
ViewDecorationsChangedEvent
|
ViewFlushedEvent
|
ViewFocusChangedEvent
...
...
src/vs/editor/common/viewModel/viewEventHandler.ts
浏览文件 @
7d098ad4
...
...
@@ -37,10 +37,7 @@ export class ViewEventHandler extends Disposable {
public
onConfigurationChanged
(
e
:
viewEvents
.
ViewConfigurationChangedEvent
):
boolean
{
return
false
;
}
public
onCursorPositionChanged
(
e
:
viewEvents
.
ViewCursorPositionChangedEvent
):
boolean
{
return
false
;
}
public
onCursorSelectionChanged
(
e
:
viewEvents
.
ViewCursorSelectionChangedEvent
):
boolean
{
public
onCursorStateChanged
(
e
:
viewEvents
.
ViewCursorStateChangedEvent
):
boolean
{
return
false
;
}
public
onDecorationsChanged
(
e
:
viewEvents
.
ViewDecorationsChangedEvent
):
boolean
{
...
...
@@ -100,14 +97,8 @@ export class ViewEventHandler extends Disposable {
}
break
;
case
viewEvents
.
ViewEventType
.
ViewCursorPositionChanged
:
if
(
this
.
onCursorPositionChanged
(
e
))
{
shouldRender
=
true
;
}
break
;
case
viewEvents
.
ViewEventType
.
ViewCursorSelectionChanged
:
if
(
this
.
onCursorSelectionChanged
(
e
))
{
case
viewEvents
.
ViewEventType
.
ViewCursorStateChanged
:
if
(
this
.
onCursorStateChanged
(
e
))
{
shouldRender
=
true
;
}
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录