Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
1588897c
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,发现更多精彩内容 >>
提交
1588897c
编写于
8月 03, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #10065
上级
09618e54
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
96 addition
and
13 deletion
+96
-13
src/vs/editor/common/controller/oneCursor.ts
src/vs/editor/common/controller/oneCursor.ts
+62
-13
src/vs/editor/test/common/controller/cursorMoveCommand.test.ts
...s/editor/test/common/controller/cursorMoveCommand.test.ts
+34
-0
未找到文件。
src/vs/editor/common/controller/oneCursor.ts
浏览文件 @
1588897c
...
...
@@ -680,7 +680,6 @@ export class OneCursorOp {
let
inSelectionMode
=
!!
moveParams
.
select
;
let
validatedViewPosition
=
cursor
.
getValidViewPosition
();
let
viewLineNumber
=
validatedViewPosition
.
lineNumber
;
let
noOfLines
=
moveParams
.
isPaged
?
(
moveParams
.
pageSize
||
cursor
.
getPageSize
())
:
moveParams
.
value
;
let
viewColumn
;
switch
(
moveParams
.
to
)
{
case
editorCommon
.
CursorMovePosition
.
Left
:
...
...
@@ -688,15 +687,9 @@ export class OneCursorOp {
case
editorCommon
.
CursorMovePosition
.
Right
:
return
this
.
moveRight
(
cursor
,
inSelectionMode
,
editorCommon
.
CursorMoveByUnit
.
HalfLine
===
moveParams
.
by
?
cursor
.
getViewHalfLineSize
(
viewLineNumber
)
:
moveParams
.
value
,
ctx
);
case
editorCommon
.
CursorMovePosition
.
Up
:
if
(
editorCommon
.
CursorMoveByUnit
.
WrappedLine
===
moveParams
.
by
)
{
return
this
.
moveUp
(
cursor
,
inSelectionMode
,
noOfLines
,
ctx
);
}
return
false
;
return
this
.
moveUp
(
cursor
,
moveParams
,
ctx
);
case
editorCommon
.
CursorMovePosition
.
Down
:
if
(
editorCommon
.
CursorMoveByUnit
.
WrappedLine
===
moveParams
.
by
)
{
return
this
.
moveDown
(
cursor
,
inSelectionMode
,
noOfLines
,
ctx
);
}
return
false
;
return
this
.
moveDown
(
cursor
,
moveParams
,
ctx
);
case
editorCommon
.
CursorMovePosition
.
WrappedLineStart
:
viewColumn
=
cursor
.
getViewLineMinColumn
(
viewLineNumber
);
break
;
...
...
@@ -915,9 +908,15 @@ export class OneCursorOp {
return
true
;
}
public
static
moveDown
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
noOfLines
:
number
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
linesCount
=
noOfLines
>
0
?
noOfLines
:
1
;
public
static
moveDown
(
cursor
:
OneCursor
,
moveArguments
:
CursorMoveArguments
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
linesCount
=
(
moveArguments
.
isPaged
?
(
moveArguments
.
pageSize
||
cursor
.
getPageSize
())
:
moveArguments
.
value
)
||
1
;
if
(
editorCommon
.
CursorMoveByUnit
.
WrappedLine
===
moveArguments
.
by
)
{
return
this
.
_moveDownByViewLines
(
cursor
,
moveArguments
.
select
,
linesCount
,
ctx
);
}
return
this
.
_moveDownByModelLines
(
cursor
,
moveArguments
.
select
,
linesCount
,
ctx
);
}
private
static
_moveDownByViewLines
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
linesCount
:
number
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
viewLineNumber
:
number
,
viewColumn
:
number
;
...
...
@@ -939,6 +938,27 @@ export class OneCursorOp {
return
true
;
}
private
static
_moveDownByModelLines
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
linesCount
:
number
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
lineNumber
:
number
,
column
:
number
;
if
(
cursor
.
hasSelection
()
&&
!
inSelectionMode
)
{
// If we are in selection mode, move down acts relative to the end of selection
let
selection
=
cursor
.
getSelection
();
lineNumber
=
selection
.
endLineNumber
;
column
=
selection
.
endColumn
;
}
else
{
let
position
=
cursor
.
getPosition
();
lineNumber
=
position
.
lineNumber
;
column
=
position
.
column
;
}
let
r
=
cursor
.
getPositionDown
(
lineNumber
,
column
,
cursor
.
getLeftoverVisibleColumns
(),
linesCount
,
true
);
ctx
.
cursorPositionChangeReason
=
editorCommon
.
CursorChangeReason
.
Explicit
;
cursor
.
moveModelPosition
(
inSelectionMode
,
r
.
lineNumber
,
r
.
column
,
r
.
leftoverVisibleColumns
,
true
);
return
true
;
}
public
static
translateDown
(
cursor
:
OneCursor
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
selection
=
cursor
.
getViewSelection
();
...
...
@@ -956,8 +976,15 @@ export class OneCursorOp {
return
true
;
}
public
static
moveUp
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
noOfLines
:
number
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
linesCount
=
noOfLines
>
0
?
noOfLines
:
1
;
public
static
moveUp
(
cursor
:
OneCursor
,
moveArguments
:
CursorMoveArguments
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
linesCount
=
(
moveArguments
.
isPaged
?
(
moveArguments
.
pageSize
||
cursor
.
getPageSize
())
:
moveArguments
.
value
)
||
1
;
if
(
editorCommon
.
CursorMoveByUnit
.
WrappedLine
===
moveArguments
.
by
)
{
return
this
.
_moveUpByViewLines
(
cursor
,
moveArguments
.
select
,
linesCount
,
ctx
);
}
return
this
.
_moveUpByModelLines
(
cursor
,
moveArguments
.
select
,
linesCount
,
ctx
);
}
private
static
_moveUpByViewLines
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
linesCount
:
number
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
viewLineNumber
:
number
,
viewColumn
:
number
;
...
...
@@ -981,6 +1008,28 @@ export class OneCursorOp {
return
true
;
}
private
static
_moveUpByModelLines
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
linesCount
:
number
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
lineNumber
:
number
,
column
:
number
;
if
(
cursor
.
hasSelection
()
&&
!
inSelectionMode
)
{
// If we are in selection mode, move up acts relative to the beginning of selection
let
selection
=
cursor
.
getSelection
();
lineNumber
=
selection
.
startLineNumber
;
column
=
selection
.
startColumn
;
}
else
{
let
position
=
cursor
.
getPosition
();
lineNumber
=
position
.
lineNumber
;
column
=
position
.
column
;
}
let
r
=
cursor
.
getPositionUp
(
lineNumber
,
column
,
cursor
.
getLeftoverVisibleColumns
(),
linesCount
,
true
);
ctx
.
cursorPositionChangeReason
=
editorCommon
.
CursorChangeReason
.
Explicit
;
cursor
.
moveModelPosition
(
inSelectionMode
,
r
.
lineNumber
,
r
.
column
,
r
.
leftoverVisibleColumns
,
true
);
return
true
;
}
public
static
translateUp
(
cursor
:
OneCursor
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
selection
=
cursor
.
getViewSelection
();
...
...
src/vs/editor/test/common/controller/cursorMoveCommand.test.ts
浏览文件 @
1588897c
...
...
@@ -273,6 +273,32 @@ suite('Cursor move command test', () => {
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move up by model line cursor move command
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
3
,
5
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveUpByModelLine
(
thisCursor
,
2
);
cursorEqual
(
thisCursor
,
1
,
5
);
moveUpByModelLine
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move down by model line cursor move command
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
3
,
5
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveDownByModelLine
(
thisCursor
,
2
);
cursorEqual
(
thisCursor
,
5
,
2
);
moveDownByModelLine
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
5
,
2
);
});
test
(
'
move up with selection by cursor move command
'
,
()
=>
{
thisCursor
=
aCursor
();
...
...
@@ -488,10 +514,18 @@ function moveUp(cursor: Cursor, noOfLines: number= 1, select?: boolean) {
move
(
cursor
,
{
to
:
CursorMovePosition
.
Up
,
by
:
CursorMoveByUnit
.
WrappedLine
,
value
:
noOfLines
,
select
:
select
});
}
function
moveUpByModelLine
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
select
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMovePosition
.
Up
,
value
:
noOfLines
,
select
:
select
});
}
function
moveDown
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
select
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMovePosition
.
Down
,
by
:
CursorMoveByUnit
.
WrappedLine
,
value
:
noOfLines
,
select
:
select
});
}
function
moveDownByModelLine
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
select
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMovePosition
.
Down
,
value
:
noOfLines
,
select
:
select
});
}
function
moveToTop
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
select
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMovePosition
.
ViewPortTop
,
value
:
noOfLines
,
select
:
select
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录