Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
94c647f2
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
94c647f2
编写于
5月 22, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplification in cursor eventing
上级
9f896956
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
43 deletion
+22
-43
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+5
-4
src/vs/editor/common/controller/coreCommands.ts
src/vs/editor/common/controller/coreCommands.ts
+3
-1
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+13
-28
src/vs/editor/common/controller/cursorCollection.ts
src/vs/editor/common/controller/cursorCollection.ts
+0
-9
src/vs/editor/common/controller/cursorCommon.ts
src/vs/editor/common/controller/cursorCommon.ts
+1
-1
未找到文件。
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
94c647f2
...
...
@@ -279,16 +279,17 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
}
}
private
_sendRevealRange
(
r
ange
:
Range
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
):
void
{
private
_sendRevealRange
(
modelR
ange
:
Range
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
):
void
{
if
(
!
this
.
model
||
!
this
.
cursor
)
{
return
;
}
if
(
!
Range
.
isIRange
(
r
ange
))
{
if
(
!
Range
.
isIRange
(
modelR
ange
))
{
throw
new
Error
(
'
Invalid arguments
'
);
}
let
validatedRange
=
this
.
model
.
validateRange
(
range
);
const
validatedModelRange
=
this
.
model
.
validateRange
(
modelRange
);
const
viewRange
=
this
.
viewModel
.
coordinatesConverter
.
convertModelRangeToViewRange
(
validatedModelRange
);
this
.
cursor
.
emitCursorRevealRange
(
v
alidatedRange
,
null
,
verticalType
,
revealHorizontal
);
this
.
cursor
.
emitCursorRevealRange
(
v
iewRange
,
verticalType
,
revealHorizontal
);
}
public
revealLine
(
lineNumber
:
number
):
void
{
...
...
src/vs/editor/common/controller/coreCommands.ts
浏览文件 @
94c647f2
...
...
@@ -1405,7 +1405,9 @@ export namespace CoreNavigationCommands {
}
}
cursors
.
revealRange
(
false
,
range
,
null
,
revealAt
);
const
viewRange
=
cursors
.
context
.
convertModelRangeToViewRange
(
range
);
cursors
.
revealRange
(
false
,
viewRange
,
revealAt
);
}
});
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
94c647f2
...
...
@@ -204,8 +204,8 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this
.
_revealRange
(
target
,
viewEvents
.
VerticalRevealType
.
Simple
,
horizontal
);
}
public
revealRange
(
revealHorizontal
:
boolean
,
modelRange
:
Range
,
viewRange
:
Range
,
verticalType
:
viewEvents
.
VerticalRevealType
)
{
this
.
emitCursorRevealRange
(
modelRange
,
viewRange
,
verticalType
,
revealHorizontal
);
public
revealRange
(
revealHorizontal
:
boolean
,
viewRange
:
Range
,
verticalType
:
viewEvents
.
VerticalRevealType
)
{
this
.
emitCursorRevealRange
(
viewRange
,
verticalType
,
revealHorizontal
);
}
public
scrollTo
(
desiredScrollTop
:
number
):
void
{
...
...
@@ -368,19 +368,11 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
false
;
}
this
.
_emitStateChanged
(
source
,
reason
);
return
true
;
}
private
_emitStateChanged
(
source
:
string
,
reason
:
CursorChangeReason
):
void
{
source
=
source
||
'
keyboard
'
;
const
positions
=
this
.
_cursors
.
getPositions
();
let
isInEditableRange
:
boolean
=
true
;
if
(
this
.
_model
.
hasEditableRange
())
{
const
editableRange
=
this
.
_model
.
getEditableRange
();
if
(
!
editableRange
.
containsPosition
(
positions
[
0
]
))
{
if
(
!
editableRange
.
containsPosition
(
newState
.
cursorState
[
0
].
modelState
.
position
))
{
isInEditableRange
=
false
;
}
}
...
...
@@ -392,47 +384,40 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this
.
_emit
([
new
viewEvents
.
ViewCursorStateChangedEvent
(
viewSelections
,
isInEditableRange
)]);
// Only after the view has been notified, let the rest of the world know...
this
.
_onDidChange
.
fire
(
new
CursorStateChangedEvent
(
selections
,
source
,
reason
));
this
.
_onDidChange
.
fire
(
new
CursorStateChangedEvent
(
selections
,
source
||
'
keyboard
'
,
reason
));
return
true
;
}
private
_revealRange
(
revealTarget
:
RevealTarget
,
verticalType
:
viewEvents
.
VerticalRevealType
,
revealHorizontal
:
boolean
):
void
{
const
positions
=
this
.
_cursors
.
getPositions
();
const
viewPositions
=
this
.
_cursors
.
getViewPositions
();
let
position
=
positions
[
0
];
let
viewPosition
=
viewPositions
[
0
];
if
(
revealTarget
===
RevealTarget
.
TopMost
)
{
for
(
let
i
=
1
;
i
<
positions
.
length
;
i
++
)
{
if
(
positions
[
i
].
isBefore
(
position
))
{
position
=
positions
[
i
];
for
(
let
i
=
1
;
i
<
viewPositions
.
length
;
i
++
)
{
if
(
viewPositions
[
i
].
isBefore
(
viewPosition
))
{
viewPosition
=
viewPositions
[
i
];
}
}
}
else
if
(
revealTarget
===
RevealTarget
.
BottomMost
)
{
for
(
let
i
=
1
;
i
<
positions
.
length
;
i
++
)
{
if
(
position
.
isBeforeOrEqual
(
positions
[
i
]))
{
position
=
positions
[
i
];
for
(
let
i
=
1
;
i
<
viewPositions
.
length
;
i
++
)
{
if
(
viewPosition
.
isBeforeOrEqual
(
viewPositions
[
i
]))
{
viewPosition
=
viewPositions
[
i
];
}
}
}
else
{
if
(
p
ositions
.
length
>
1
)
{
if
(
viewP
ositions
.
length
>
1
)
{
// no revealing!
return
;
}
}
const
range
=
new
Range
(
position
.
lineNumber
,
position
.
column
,
position
.
lineNumber
,
position
.
column
);
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
emitCursorRevealRange
(
range
,
viewRange
,
verticalType
,
revealHorizontal
);
this
.
emitCursorRevealRange
(
viewRange
,
verticalType
,
revealHorizontal
);
}
public
emitCursorRevealRange
(
range
:
Range
,
viewRange
:
Range
,
verticalType
:
viewEvents
.
VerticalRevealType
,
revealHorizontal
:
boolean
)
{
// Ensure event has viewRange
if
(
!
viewRange
)
{
viewRange
=
this
.
context
.
convertModelRangeToViewRange
(
range
);
}
public
emitCursorRevealRange
(
viewRange
:
Range
,
verticalType
:
viewEvents
.
VerticalRevealType
,
revealHorizontal
:
boolean
)
{
this
.
_emit
([
new
viewEvents
.
ViewRevealRangeRequestEvent
(
viewRange
,
verticalType
,
revealHorizontal
)]);
}
...
...
src/vs/editor/common/controller/cursorCollection.ts
浏览文件 @
94c647f2
...
...
@@ -60,15 +60,6 @@ export class CursorCollection {
return
result
;
}
public
getPositions
():
Position
[]
{
let
result
:
Position
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
modelState
.
position
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
[
i
+
1
]
=
this
.
secondaryCursors
[
i
].
modelState
.
position
;
}
return
result
;
}
public
getViewPositions
():
Position
[]
{
let
result
:
Position
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
viewState
.
position
;
...
...
src/vs/editor/common/controller/cursorCommon.ts
浏览文件 @
94c647f2
...
...
@@ -42,7 +42,7 @@ export interface ICursors {
setStates
(
source
:
string
,
reason
:
CursorChangeReason
,
states
:
CursorState
[]):
void
;
reveal
(
horizontal
:
boolean
,
target
:
RevealTarget
):
void
;
revealRange
(
revealHorizontal
:
boolean
,
modelRange
:
Range
,
viewRange
:
Range
,
verticalType
:
VerticalRevealType
):
void
;
revealRange
(
revealHorizontal
:
boolean
,
viewRange
:
Range
,
verticalType
:
VerticalRevealType
):
void
;
scrollTo
(
desiredScrollTop
:
number
):
void
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录