Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
35d592de
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,发现更多精彩内容 >>
提交
35d592de
编写于
7月 20, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests
上级
73551134
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
464 addition
and
199 deletion
+464
-199
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+1
-1
src/vs/editor/test/common/commands/commandTestUtils.ts
src/vs/editor/test/common/commands/commandTestUtils.ts
+0
-1
src/vs/editor/test/common/controller/cursor.test.ts
src/vs/editor/test/common/controller/cursor.test.ts
+1
-197
src/vs/editor/test/common/controller/cursorMoveCommand.test.ts
...s/editor/test/common/controller/cursorMoveCommand.test.ts
+462
-0
未找到文件。
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
35d592de
...
...
@@ -600,7 +600,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
ViewImpl.getVisibleRangeInViewport: View is disposed
'
);
}
let
visibleRange
=
this
.
layoutProvider
.
getLinesViewportData
().
visibleRange
;
let
visibleRange
=
this
.
layoutProvider
.
getLinesViewportData
().
visibleRange
;
return
this
.
_context
.
model
.
convertViewRangeToModelRange
(
visibleRange
);
}
...
...
src/vs/editor/test/common/commands/commandTestUtils.ts
浏览文件 @
35d592de
...
...
@@ -6,7 +6,6 @@
import
*
as
assert
from
'
assert
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
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
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
...
...
src/vs/editor/test/common/controller/cursor.test.ts
浏览文件 @
35d592de
...
...
@@ -13,7 +13,7 @@ import {Selection} from 'vs/editor/common/core/selection';
import
{
EndOfLinePreference
,
EventType
,
Handler
,
IPosition
,
ISelection
,
IEditorOptions
,
DefaultEndOfLine
,
ITextModelCreationOptions
,
ICommand
,
ITokenizedModel
,
IEditOperationBuilder
,
ICursorStateComputerData
,
CursorMoveViewPosition
ITokenizedModel
,
IEditOperationBuilder
,
ICursorStateComputerData
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
IMode
,
IndentAction
}
from
'
vs/editor/common/modes
'
;
...
...
@@ -31,40 +31,6 @@ function cursorCommand(cursor: Cursor, command: string, extraData?: any, overwri
cursor
.
trigger
(
overwriteSource
||
'
tests
'
,
command
,
extraData
);
}
// Move command
function
move
(
cursor
:
Cursor
,
args
:
any
)
{
cursorCommand
(
cursor
,
H
.
CursorMove
,
args
);
}
function
moveToLineStart
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineStart
});
}
function
moveToLineFirstNonWhiteSpaceCharacter
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineFirstNonWhitespaceCharacter
});
}
function
moveToLineCenter
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineColumnCenter
});
}
function
moveToLineEnd
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineEnd
});
}
function
moveToLineLastNonWhiteSpaceCharacter
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineLastNonWhitespaceCharacter
});
}
function
moveUpByCursorMoveCommand
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
inSelectionMode
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineUp
,
noOfLines
:
noOfLines
,
inSelectionMode
:
inSelectionMode
});
}
function
moveDownByCursorMoveCommand
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
inSelectionMode
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineDown
,
noOfLines
:
noOfLines
,
inSelectionMode
:
inSelectionMode
});
}
function
moveTo
(
cursor
:
Cursor
,
lineNumber
:
number
,
column
:
number
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
MoveToSelect
:
H
.
MoveTo
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
...
...
@@ -226,168 +192,6 @@ suite('Editor Controller - Cursor', () => {
cursorEqual
(
thisCursor
,
1
,
1
);
});
// --------- cursor move command
test
(
'
move to first character of line from middle
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
8
);
moveToLineStart
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move to first character of line from first non white space character
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
6
);
moveToLineStart
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move to first character of line from first character
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
1
);
moveToLineStart
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move to first non white space character of line from middle
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
8
);
moveToLineFirstNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
6
);
});
test
(
'
move to first non white space character of line from first non white space character
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
6
);
moveToLineFirstNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
6
);
});
test
(
'
move to first non white space character of line from first character
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
1
);
moveToLineFirstNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
6
);
});
test
(
'
move to end of line from middle
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
8
);
moveToLineEnd
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
test
(
'
move to end of line from last non white space character
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
moveToLineEnd
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
test
(
'
move to end of line from line end
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
moveToLineEnd
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
test
(
'
move to last non white space character from middle
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
8
);
moveToLineLastNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
});
test
(
'
move to last non white space character from last non white space character
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
moveToLineLastNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
});
test
(
'
move to last non white space character from line end
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
moveToLineLastNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
});
test
(
'
move to center of line not from center
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
8
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move to center of line from center
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
11
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move to center of line from start
'
,
()
=>
{
moveToLineStart
(
thisCursor
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move to center of line from end
'
,
()
=>
{
moveToLineEnd
(
thisCursor
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move up by cursor move command
'
,
()
=>
{
moveTo
(
thisCursor
,
3
,
5
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
2
);
cursorEqual
(
thisCursor
,
1
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move up with selection by cursor move command
'
,
()
=>
{
moveTo
(
thisCursor
,
3
,
5
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
,
true
);
cursorEqual
(
thisCursor
,
2
,
2
,
3
,
5
);
moveUp
(
thisCursor
,
1
,
true
);
cursorEqual
(
thisCursor
,
1
,
5
,
3
,
5
);
});
test
(
'
move up and down with tabs by cursor move command
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
5
);
cursorEqual
(
thisCursor
,
1
,
5
);
moveDownByCursorMoveCommand
(
thisCursor
,
4
);
cursorEqual
(
thisCursor
,
5
,
2
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
4
,
1
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
2
,
2
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
1
,
5
);
});
test
(
'
move up and down with end of lines starting from a long one by cursor move command
'
,
()
=>
{
moveToEndOfLine
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
moveToEndOfLine
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
moveDownByCursorMoveCommand
(
thisCursor
,
2
);
cursorEqual
(
thisCursor
,
3
,
LINE3
.
length
+
1
);
moveDownByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
4
,
LINE4
.
length
+
1
);
moveDownByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
5
,
LINE5
.
length
+
1
);
moveUpByCursorMoveCommand
(
thisCursor
,
4
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
// --- end of cursor move command tests
test
(
'
move
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
2
);
cursorEqual
(
thisCursor
,
1
,
2
);
...
...
src/vs/editor/test/common/controller/cursorMoveCommand.test.ts
0 → 100644
浏览文件 @
35d592de
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Handler
,
IEditorOptions
,
ITextModelCreationOptions
,
CursorMoveViewPosition
,
ISelection
,
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
IMode
}
from
'
vs/editor/common/modes
'
;
import
{
MockConfiguration
}
from
'
vs/editor/test/common/mocks/mockConfiguration
'
;
import
{
viewModelHelper
as
aViewModelHelper
}
from
'
vs/editor/test/common/editorTestUtils
'
;
import
{
IViewModelHelper
}
from
'
vs/editor/common/controller/oneCursor
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
let
H
=
Handler
;
suite
(
'
Cursor move command test
'
,
()
=>
{
const
LINE1
=
'
\t
My First Line
\t
'
;
const
LINE2
=
'
\t
My Second Line
'
;
const
LINE3
=
'
Third Line💩
'
;
const
LINE4
=
''
;
const
LINE5
=
'
1
'
;
let
thisModel
:
Model
;
let
thisConfiguration
:
MockConfiguration
;
let
thisCursor
:
Cursor
;
setup
(()
=>
{
let
text
=
LINE1
+
'
\r\n
'
+
LINE2
+
'
\n
'
+
LINE3
+
'
\n
'
+
LINE4
+
'
\r\n
'
+
LINE5
;
thisModel
=
Model
.
createFromString
(
text
);
thisConfiguration
=
new
MockConfiguration
(
null
);
});
teardown
(()
=>
{
thisCursor
.
dispose
();
thisModel
.
dispose
();
thisConfiguration
.
dispose
();
});
test
(
'
move to first character of line from middle
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
8
);
moveToLineStart
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move to first character of line from first non white space character
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
6
);
moveToLineStart
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move to first character of line from first character
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
1
);
moveToLineStart
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move to first non white space character of line from middle
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
8
);
moveToLineFirstNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
6
);
});
test
(
'
move to first non white space character of line from first non white space character
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
6
);
moveToLineFirstNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
6
);
});
test
(
'
move to first non white space character of line from first character
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
1
);
moveToLineFirstNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
6
);
});
test
(
'
move to end of line from middle
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
8
);
moveToLineEnd
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
test
(
'
move to end of line from last non white space character
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
moveToLineEnd
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
test
(
'
move to end of line from line end
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
moveToLineEnd
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
test
(
'
move to last non white space character from middle
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
8
);
moveToLineLastNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
});
test
(
'
move to last non white space character from last non white space character
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
moveToLineLastNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
});
test
(
'
move to last non white space character from line end
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
moveToLineLastNonWhiteSpaceCharacter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
});
test
(
'
move to center of line not from center
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
8
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move to center of line from center
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
11
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move to center of line from start
'
,
()
=>
{
thisCursor
=
aCursor
();
moveToLineStart
(
thisCursor
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move to center of line from end
'
,
()
=>
{
thisCursor
=
aCursor
();
moveToLineEnd
(
thisCursor
);
moveToLineCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
11
);
});
test
(
'
move up by cursor move command
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
3
,
5
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
2
);
cursorEqual
(
thisCursor
,
1
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
1
,
1
);
});
test
(
'
move up with selection by cursor move command
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
3
,
5
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
,
true
);
cursorEqual
(
thisCursor
,
2
,
2
,
3
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
,
true
);
cursorEqual
(
thisCursor
,
1
,
5
,
3
,
5
);
});
test
(
'
move up and down with tabs by cursor move command
'
,
()
=>
{
thisCursor
=
aCursor
();
moveTo
(
thisCursor
,
1
,
5
);
cursorEqual
(
thisCursor
,
1
,
5
);
moveDownByCursorMoveCommand
(
thisCursor
,
4
);
cursorEqual
(
thisCursor
,
5
,
2
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
4
,
1
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
3
,
5
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
2
,
2
);
moveUpByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
1
,
5
);
});
test
(
'
move up and down with end of lines starting from a long one by cursor move command
'
,
()
=>
{
thisCursor
=
aCursor
();
moveToEndOfLine
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
-
1
);
moveToEndOfLine
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
moveDownByCursorMoveCommand
(
thisCursor
,
2
);
cursorEqual
(
thisCursor
,
3
,
LINE3
.
length
+
1
);
moveDownByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
4
,
LINE4
.
length
+
1
);
moveDownByCursorMoveCommand
(
thisCursor
,
1
);
cursorEqual
(
thisCursor
,
5
,
LINE5
.
length
+
1
);
moveUpByCursorMoveCommand
(
thisCursor
,
4
);
cursorEqual
(
thisCursor
,
1
,
LINE1
.
length
+
1
);
});
test
(
'
move to view top line moves to first visible line if it is first line
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
1
,
1
,
10
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
2
,
2
);
moveToTop
(
thisCursor
);
cursorEqual
(
thisCursor
,
1
,
6
);
});
test
(
'
move to view top line moves to top visible line when first line is not visible
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
2
,
1
,
10
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
4
,
1
);
moveToTop
(
thisCursor
);
cursorEqual
(
thisCursor
,
2
,
2
);
});
test
(
'
move to view top line moves to nth line from top
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
1
,
1
,
10
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
4
,
1
);
moveToTop
(
thisCursor
,
3
);
cursorEqual
(
thisCursor
,
3
,
5
);
});
test
(
'
move to view top line moves to last line if n is greater than last visible line number
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
1
,
1
,
3
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
2
,
2
);
moveToTop
(
thisCursor
,
4
);
cursorEqual
(
thisCursor
,
3
,
5
);
});
test
(
'
move to view center line moves to the center line
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentCenteredRange
=
()
=>
new
Range
(
3
,
1
,
3
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
2
,
2
);
moveToCenter
(
thisCursor
);
cursorEqual
(
thisCursor
,
3
,
5
);
});
test
(
'
move to view bottom line moves to last visible line if it is last line
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
1
,
1
,
5
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
2
,
2
);
moveToBottom
(
thisCursor
);
cursorEqual
(
thisCursor
,
5
,
1
);
});
test
(
'
move to view bottom line moves to last visible line when last line is not visible
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
2
,
1
,
3
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
2
,
2
);
moveToBottom
(
thisCursor
);
cursorEqual
(
thisCursor
,
3
,
5
);
});
test
(
'
move to view bottom line moves to nth line from bottom
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
1
,
1
,
5
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
4
,
1
);
moveToBottom
(
thisCursor
,
3
);
cursorEqual
(
thisCursor
,
3
,
5
);
});
test
(
'
move to view bottom line moves to first line if n is lesser than first visible line number
'
,
()
=>
{
let
viewModelHelper
=
aViewModelHelper
(
thisModel
);
viewModelHelper
.
getCurrentVisibleRange
=
()
=>
new
Range
(
2
,
1
,
5
,
1
);
thisCursor
=
aCursor
(
viewModelHelper
);
moveTo
(
thisCursor
,
4
,
1
);
moveToBottom
(
thisCursor
,
5
);
cursorEqual
(
thisCursor
,
2
,
2
);
});
function
aCursor
(
viewModelHelper
?:
IViewModelHelper
):
Cursor
{
return
new
Cursor
(
1
,
thisConfiguration
,
thisModel
,
viewModelHelper
||
aViewModelHelper
(
thisModel
),
false
);
}
});
interface
ICursorOpts
{
text
:
string
[];
mode
?:
IMode
;
modelOpts
?:
ITextModelCreationOptions
;
editorOpts
?:
IEditorOptions
;
}
// --------- utils
function
cursorCommand
(
cursor
:
Cursor
,
command
:
string
,
extraData
?:
any
,
overwriteSource
?:
string
)
{
cursor
.
trigger
(
overwriteSource
||
'
tests
'
,
command
,
extraData
);
}
// Move command
function
move
(
cursor
:
Cursor
,
args
:
any
)
{
cursorCommand
(
cursor
,
H
.
CursorMove
,
args
);
}
function
moveToLineStart
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineStart
});
}
function
moveToLineFirstNonWhiteSpaceCharacter
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineFirstNonWhitespaceCharacter
});
}
function
moveToLineCenter
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineColumnCenter
});
}
function
moveToLineEnd
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineEnd
});
}
function
moveToLineLastNonWhiteSpaceCharacter
(
cursor
:
Cursor
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineLastNonWhitespaceCharacter
});
}
function
moveUpByCursorMoveCommand
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
inSelectionMode
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineUp
,
noOfLines
:
noOfLines
,
inSelectionMode
:
inSelectionMode
});
}
function
moveDownByCursorMoveCommand
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
inSelectionMode
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineDown
,
noOfLines
:
noOfLines
,
inSelectionMode
:
inSelectionMode
});
}
function
moveToTop
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
inSelectionMode
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineViewTop
,
noOfLines
:
noOfLines
,
inSelectionMode
:
inSelectionMode
});
}
function
moveToCenter
(
cursor
:
Cursor
,
inSelectionMode
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineViewCenter
,
inSelectionMode
:
inSelectionMode
});
}
function
moveToBottom
(
cursor
:
Cursor
,
noOfLines
:
number
=
1
,
inSelectionMode
?:
boolean
)
{
move
(
cursor
,
{
to
:
CursorMoveViewPosition
.
LineViewBottom
,
noOfLines
:
noOfLines
,
inSelectionMode
:
inSelectionMode
});
}
function
cursorEqual
(
cursor
:
Cursor
,
posLineNumber
:
number
,
posColumn
:
number
,
selLineNumber
:
number
=
posLineNumber
,
selColumn
:
number
=
posColumn
)
{
positionEqual
(
cursor
.
getPosition
(),
posLineNumber
,
posColumn
);
selectionEqual
(
cursor
.
getSelection
(),
posLineNumber
,
posColumn
,
selLineNumber
,
selColumn
);
}
function
positionEqual
(
position
:
IPosition
,
lineNumber
:
number
,
column
:
number
)
{
assert
.
deepEqual
({
lineNumber
:
position
.
lineNumber
,
column
:
position
.
column
},
{
lineNumber
:
lineNumber
,
column
:
column
},
'
position equal
'
);
}
function
selectionEqual
(
selection
:
ISelection
,
posLineNumber
:
number
,
posColumn
:
number
,
selLineNumber
:
number
,
selColumn
:
number
)
{
assert
.
deepEqual
({
selectionStartLineNumber
:
selection
.
selectionStartLineNumber
,
selectionStartColumn
:
selection
.
selectionStartColumn
,
positionLineNumber
:
selection
.
positionLineNumber
,
positionColumn
:
selection
.
positionColumn
},
{
selectionStartLineNumber
:
selLineNumber
,
selectionStartColumn
:
selColumn
,
positionLineNumber
:
posLineNumber
,
positionColumn
:
posColumn
},
'
selection equal
'
);
}
function
moveTo
(
cursor
:
Cursor
,
lineNumber
:
number
,
column
:
number
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
MoveToSelect
:
H
.
MoveTo
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
function
moveToEndOfLine
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorEndSelect
:
H
.
CursorEnd
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录