Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
20f903c0
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,发现更多精彩内容 >>
提交
20f903c0
编写于
3月 25, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract word move commands out of editor core
上级
3dfd9dee
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
581 addition
and
377 deletion
+581
-377
src/vs/editor/browser/editor.all.ts
src/vs/editor/browser/editor.all.ts
+3
-2
src/vs/editor/common/config/config.ts
src/vs/editor/common/config/config.ts
+2
-19
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+0
-24
src/vs/editor/common/controller/cursorWordOperations.ts
src/vs/editor/common/controller/cursorWordOperations.ts
+21
-33
src/vs/editor/common/controller/oneCursor.ts
src/vs/editor/common/controller/oneCursor.ts
+1
-15
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+0
-16
src/vs/editor/common/editorCommonExtensions.ts
src/vs/editor/common/editorCommonExtensions.ts
+4
-0
src/vs/editor/contrib/wordOperations/common/wordOperations.ts
...vs/editor/contrib/wordOperations/common/wordOperations.ts
+243
-0
src/vs/editor/contrib/wordOperations/test/common/wordOperations.test.ts
...contrib/wordOperations/test/common/wordOperations.test.ts
+306
-0
src/vs/editor/test/common/controller/cursor.test.ts
src/vs/editor/test/common/controller/cursor.test.ts
+0
-255
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+0
-12
src/vs/workbench/parts/debug/browser/debugEditorActions.ts
src/vs/workbench/parts/debug/browser/debugEditorActions.ts
+1
-1
未找到文件。
src/vs/editor/browser/editor.all.ts
浏览文件 @
20f903c0
...
...
@@ -17,12 +17,13 @@ import 'vs/editor/contrib/codelens/browser/codelens';
import
'
vs/editor/contrib/comment/common/comment
'
;
import
'
vs/editor/contrib/contextmenu/browser/contextmenu
'
;
import
'
vs/editor/contrib/diffNavigator/common/diffNavigator
'
;
import
'
vs/editor/contrib/dnd/browser/dnd
'
;
import
'
vs/editor/contrib/find/browser/find
'
;
import
'
vs/editor/contrib/folding/browser/folding
'
;
import
'
vs/editor/contrib/format/browser/formatActions
'
;
import
'
vs/editor/contrib/goToDeclaration/browser/goToDeclaration
'
;
import
'
vs/editor/contrib/gotoError/browser/gotoError
'
;
import
'
vs/editor/contrib/hover/browser/hover
'
;
import
'
vs/editor/contrib/dnd/browser/dnd
'
;
import
'
vs/css!vs/editor/contrib/inPlaceReplace/browser/inPlaceReplace
'
;
import
'
vs/editor/contrib/inPlaceReplace/common/inPlaceReplace
'
;
import
'
vs/editor/contrib/iPadShowKeyboard/browser/iPadShowKeyboard
'
;
...
...
@@ -40,4 +41,4 @@ import 'vs/editor/contrib/snippet/browser/snippet';
import
'
vs/editor/contrib/suggest/browser/suggestController
'
;
import
'
vs/editor/contrib/toggleTabFocusMode/common/toggleTabFocusMode
'
;
import
'
vs/editor/contrib/wordHighlighter/common/wordHighlighter
'
;
import
'
vs/editor/contrib/
folding/browser/folding
'
;
import
'
vs/editor/contrib/
wordOperations/common/wordOperations
'
;
src/vs/editor/common/config/config.ts
浏览文件 @
20f903c0
...
...
@@ -95,7 +95,7 @@ export abstract class EditorCommand extends Command {
this
.
_callback
=
opts
.
handler
;
}
p
rotected
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
args
:
any
):
void
{
p
ublic
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
args
:
any
):
void
{
let
controller
=
controllerGetter
(
editor
);
if
(
controller
)
{
this
.
_callback
(
controllerGetter
(
editor
));
...
...
@@ -128,7 +128,7 @@ export abstract class EditorCommand extends Command {
});
}
p
rotected
abstract
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
args
:
any
):
void
|
TPromise
<
void
>
;
p
ublic
abstract
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
args
:
any
):
void
|
TPromise
<
void
>
;
}
export
function
findFocusedEditor
(
commandId
:
string
,
accessor
:
ServicesAccessor
,
complain
:
boolean
):
editorCommon
.
ICommonCodeEditor
{
...
...
@@ -602,23 +602,6 @@ registerCommand(new CoreCommand({
}
}));
registerCommand
(
new
WordCommand
(
H
.
CursorWordStartLeft
,
false
,
KeyCode
.
LeftArrow
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordEndLeft
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordLeft
));
registerCommand
(
new
WordCommand
(
H
.
CursorWordStartLeftSelect
,
true
,
KeyCode
.
LeftArrow
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordEndLeftSelect
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordLeftSelect
));
registerCommand
(
new
WordCommand
(
H
.
CursorWordEndRight
,
false
,
KeyCode
.
RightArrow
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordStartRight
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordRight
));
registerCommand
(
new
WordCommand
(
H
.
CursorWordEndRightSelect
,
true
,
KeyCode
.
RightArrow
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordStartRightSelect
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
CursorWordRightSelect
));
registerCommand
(
new
WordCommand
(
H
.
DeleteWordLeft
,
false
,
KeyCode
.
Backspace
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
DeleteWordStartLeft
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
DeleteWordEndLeft
,
EditorContextKeys
.
Writable
));
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
20f903c0
...
...
@@ -892,25 +892,9 @@ export class Cursor extends EventEmitter {
this
.
_handlers
[
H
.
CursorLeft
]
=
(
ctx
)
=>
this
.
_moveLeft
(
false
,
ctx
);
this
.
_handlers
[
H
.
CursorLeftSelect
]
=
(
ctx
)
=>
this
.
_moveLeft
(
true
,
ctx
);
this
.
_handlers
[
H
.
CursorWordLeft
]
=
(
ctx
)
=>
this
.
_moveWordLeft
(
false
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
CursorWordStartLeft
]
=
(
ctx
)
=>
this
.
_moveWordLeft
(
false
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
CursorWordEndLeft
]
=
(
ctx
)
=>
this
.
_moveWordLeft
(
false
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
CursorWordLeftSelect
]
=
(
ctx
)
=>
this
.
_moveWordLeft
(
true
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
CursorWordStartLeftSelect
]
=
(
ctx
)
=>
this
.
_moveWordLeft
(
true
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
CursorWordEndLeftSelect
]
=
(
ctx
)
=>
this
.
_moveWordLeft
(
true
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
CursorRight
]
=
(
ctx
)
=>
this
.
_moveRight
(
false
,
ctx
);
this
.
_handlers
[
H
.
CursorRightSelect
]
=
(
ctx
)
=>
this
.
_moveRight
(
true
,
ctx
);
this
.
_handlers
[
H
.
CursorWordRight
]
=
(
ctx
)
=>
this
.
_moveWordRight
(
false
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
CursorWordStartRight
]
=
(
ctx
)
=>
this
.
_moveWordRight
(
false
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
CursorWordEndRight
]
=
(
ctx
)
=>
this
.
_moveWordRight
(
false
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
CursorWordRightSelect
]
=
(
ctx
)
=>
this
.
_moveWordRight
(
true
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
CursorWordStartRightSelect
]
=
(
ctx
)
=>
this
.
_moveWordRight
(
true
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
CursorWordEndRightSelect
]
=
(
ctx
)
=>
this
.
_moveWordRight
(
true
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
CursorUp
]
=
(
ctx
)
=>
this
.
_moveUp
(
false
,
false
,
ctx
);
this
.
_handlers
[
H
.
CursorUpSelect
]
=
(
ctx
)
=>
this
.
_moveUp
(
true
,
false
,
ctx
);
this
.
_handlers
[
H
.
CursorDown
]
=
(
ctx
)
=>
this
.
_moveDown
(
false
,
false
,
ctx
);
...
...
@@ -1227,10 +1211,6 @@ export class Cursor extends EventEmitter {
return
this
.
_cursorMove
(
ctx
);
}
private
_moveWordLeft
(
inSelectionMode
:
boolean
,
wordNavigationType
:
WordNavigationType
,
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_invokeForAll
(
ctx
,
(
cursorIndex
:
number
,
oneCursor
:
OneCursor
,
oneCtx
:
IOneCursorOperationContext
)
=>
OneCursorOp
.
moveWordLeft
(
oneCursor
,
inSelectionMode
,
wordNavigationType
,
oneCtx
));
}
private
_moveRight
(
inSelectionMode
:
boolean
,
ctx
:
IMultipleCursorOperationContext
):
boolean
{
ctx
.
eventData
=
ctx
.
eventData
||
{};
ctx
.
eventData
.
to
=
editorCommon
.
CursorMovePosition
.
Right
;
...
...
@@ -1239,10 +1219,6 @@ export class Cursor extends EventEmitter {
return
this
.
_cursorMove
(
ctx
);
}
private
_moveWordRight
(
inSelectionMode
:
boolean
,
wordNavigationType
:
WordNavigationType
,
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_invokeForAll
(
ctx
,
(
cursorIndex
:
number
,
oneCursor
:
OneCursor
,
oneCtx
:
IOneCursorOperationContext
)
=>
OneCursorOp
.
moveWordRight
(
oneCursor
,
inSelectionMode
,
wordNavigationType
,
oneCtx
));
}
private
_moveDown
(
inSelectionMode
:
boolean
,
isPaged
:
boolean
,
ctx
:
IMultipleCursorOperationContext
):
boolean
{
ctx
.
eventData
=
ctx
.
eventData
||
{};
ctx
.
eventData
.
to
=
editorCommon
.
CursorMovePosition
.
Down
;
...
...
src/vs/editor/common/controller/cursorWordOperations.ts
浏览文件 @
20f903c0
...
...
@@ -36,7 +36,7 @@ export const enum WordType {
Separator
=
2
}
const
enum
CharacterClass
{
export
const
enum
Word
CharacterClass
{
Regular
=
0
,
Whitespace
=
1
,
WordSeparator
=
2
...
...
@@ -47,17 +47,17 @@ export const enum WordNavigationType {
WordEnd
=
1
}
class
WordCharacterClassifier
extends
CharacterClassifier
<
CharacterClass
>
{
export
class
WordCharacterClassifier
extends
CharacterClassifier
<
Word
CharacterClass
>
{
constructor
(
wordSeparators
:
string
)
{
super
(
CharacterClass
.
Regular
);
super
(
Word
CharacterClass
.
Regular
);
for
(
let
i
=
0
,
len
=
wordSeparators
.
length
;
i
<
len
;
i
++
)
{
this
.
set
(
wordSeparators
.
charCodeAt
(
i
),
CharacterClass
.
WordSeparator
);
this
.
set
(
wordSeparators
.
charCodeAt
(
i
),
Word
CharacterClass
.
WordSeparator
);
}
this
.
set
(
CharCode
.
Space
,
CharacterClass
.
Whitespace
);
this
.
set
(
CharCode
.
Tab
,
CharacterClass
.
Whitespace
);
this
.
set
(
CharCode
.
Space
,
Word
CharacterClass
.
Whitespace
);
this
.
set
(
CharCode
.
Tab
,
Word
CharacterClass
.
Whitespace
);
}
}
...
...
@@ -72,7 +72,7 @@ function once<R>(computeFn: (input: string) => R): (input: string) => R {
};
}
le
t
getMapForWordSeparators
=
once
<
WordCharacterClassifier
>
(
export
cons
t
getMapForWordSeparators
=
once
<
WordCharacterClassifier
>
(
(
input
)
=>
new
WordCharacterClassifier
(
input
)
);
...
...
@@ -94,17 +94,17 @@ export class WordOperations {
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CharacterClass
.
Regular
)
{
if
(
chClass
===
Word
CharacterClass
.
Regular
)
{
if
(
wordType
===
WordType
.
Separator
)
{
return
this
.
_createWord
(
lineContent
,
wordType
,
chIndex
+
1
,
this
.
_findEndOfWord
(
lineContent
,
wordSeparators
,
wordType
,
chIndex
+
1
));
}
wordType
=
WordType
.
Regular
;
}
else
if
(
chClass
===
CharacterClass
.
WordSeparator
)
{
}
else
if
(
chClass
===
Word
CharacterClass
.
WordSeparator
)
{
if
(
wordType
===
WordType
.
Regular
)
{
return
this
.
_createWord
(
lineContent
,
wordType
,
chIndex
+
1
,
this
.
_findEndOfWord
(
lineContent
,
wordSeparators
,
wordType
,
chIndex
+
1
));
}
wordType
=
WordType
.
Separator
;
}
else
if
(
chClass
===
CharacterClass
.
Whitespace
)
{
}
else
if
(
chClass
===
Word
CharacterClass
.
Whitespace
)
{
if
(
wordType
!==
WordType
.
None
)
{
return
this
.
_createWord
(
lineContent
,
wordType
,
chIndex
+
1
,
this
.
_findEndOfWord
(
lineContent
,
wordSeparators
,
wordType
,
chIndex
+
1
));
}
...
...
@@ -124,13 +124,13 @@ export class WordOperations {
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CharacterClass
.
Whitespace
)
{
if
(
chClass
===
Word
CharacterClass
.
Whitespace
)
{
return
chIndex
;
}
if
(
wordType
===
WordType
.
Regular
&&
chClass
===
CharacterClass
.
WordSeparator
)
{
if
(
wordType
===
WordType
.
Regular
&&
chClass
===
Word
CharacterClass
.
WordSeparator
)
{
return
chIndex
;
}
if
(
wordType
===
WordType
.
Separator
&&
chClass
===
CharacterClass
.
Regular
)
{
if
(
wordType
===
WordType
.
Separator
&&
chClass
===
Word
CharacterClass
.
Regular
)
{
return
chIndex
;
}
}
...
...
@@ -150,17 +150,17 @@ export class WordOperations {
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CharacterClass
.
Regular
)
{
if
(
chClass
===
Word
CharacterClass
.
Regular
)
{
if
(
wordType
===
WordType
.
Separator
)
{
return
this
.
_createWord
(
lineContent
,
wordType
,
this
.
_findStartOfWord
(
lineContent
,
wordSeparators
,
wordType
,
chIndex
-
1
),
chIndex
);
}
wordType
=
WordType
.
Regular
;
}
else
if
(
chClass
===
CharacterClass
.
WordSeparator
)
{
}
else
if
(
chClass
===
Word
CharacterClass
.
WordSeparator
)
{
if
(
wordType
===
WordType
.
Regular
)
{
return
this
.
_createWord
(
lineContent
,
wordType
,
this
.
_findStartOfWord
(
lineContent
,
wordSeparators
,
wordType
,
chIndex
-
1
),
chIndex
);
}
wordType
=
WordType
.
Separator
;
}
else
if
(
chClass
===
CharacterClass
.
Whitespace
)
{
}
else
if
(
chClass
===
Word
CharacterClass
.
Whitespace
)
{
if
(
wordType
!==
WordType
.
None
)
{
return
this
.
_createWord
(
lineContent
,
wordType
,
this
.
_findStartOfWord
(
lineContent
,
wordSeparators
,
wordType
,
chIndex
-
1
),
chIndex
);
}
...
...
@@ -179,20 +179,20 @@ export class WordOperations {
let
chCode
=
lineContent
.
charCodeAt
(
chIndex
);
let
chClass
=
wordSeparators
.
get
(
chCode
);
if
(
chClass
===
CharacterClass
.
Whitespace
)
{
if
(
chClass
===
Word
CharacterClass
.
Whitespace
)
{
return
chIndex
+
1
;
}
if
(
wordType
===
WordType
.
Regular
&&
chClass
===
CharacterClass
.
WordSeparator
)
{
if
(
wordType
===
WordType
.
Regular
&&
chClass
===
Word
CharacterClass
.
WordSeparator
)
{
return
chIndex
+
1
;
}
if
(
wordType
===
WordType
.
Separator
&&
chClass
===
CharacterClass
.
Regular
)
{
if
(
wordType
===
WordType
.
Separator
&&
chClass
===
Word
CharacterClass
.
Regular
)
{
return
chIndex
+
1
;
}
}
return
0
;
}
p
rivate
static
_
moveWordLeft
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
p
ublic
static
moveWordLeft
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
let
lineNumber
=
position
.
lineNumber
;
let
column
=
position
.
column
;
...
...
@@ -225,13 +225,7 @@ export class WordOperations {
return
new
Position
(
lineNumber
,
column
);
}
public
static
moveWordLeft
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
wordNavigationType
:
WordNavigationType
):
SingleMoveOperationResult
{
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
const
position
=
this
.
_moveWordLeft
(
wordSeparators
,
model
,
cursor
.
position
,
wordNavigationType
);
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
position
.
lineNumber
,
position
.
column
,
0
,
true
,
CursorChangeReason
.
Explicit
);
}
private
static
_moveWordRight
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
public
static
moveWordRight
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
let
lineNumber
=
position
.
lineNumber
;
let
column
=
position
.
column
;
...
...
@@ -264,12 +258,6 @@ export class WordOperations {
return
new
Position
(
lineNumber
,
column
);
}
public
static
moveWordRight
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
wordNavigationType
:
WordNavigationType
):
SingleMoveOperationResult
{
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
const
position
=
this
.
_moveWordRight
(
wordSeparators
,
model
,
cursor
.
position
,
wordNavigationType
);
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
position
.
lineNumber
,
position
.
column
,
0
,
true
,
CursorChangeReason
.
Explicit
);
}
private
static
_deleteWordLeftWhitespace
(
model
:
ICursorSimpleModel
,
position
:
Position
):
Range
{
const
lineContent
=
model
.
getLineContent
(
position
.
lineNumber
);
const
startIndex
=
position
.
column
-
2
;
...
...
src/vs/editor/common/controller/oneCursor.ts
浏览文件 @
20f903c0
...
...
@@ -12,7 +12,7 @@ import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
MoveOperations
,
SingleMoveOperationResult
}
from
'
vs/editor/common/controller/cursorMoveOperations
'
;
import
{
WordOperations
,
WordNavigationType
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
import
{
WordOperations
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
import
{
ICoordinatesConverter
}
from
'
vs/editor/common/viewModel/viewModel
'
;
export
interface
IOneCursorOperationContext
{
...
...
@@ -616,13 +616,6 @@ export class OneCursorOp {
);
}
public
static
moveWordLeft
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
wordNavigationType
:
WordNavigationType
,
ctx
:
IOneCursorOperationContext
):
boolean
{
return
this
.
_applyMoveOperationResult
(
cursor
,
ctx
,
this
.
_fromModelCursorState
(
cursor
,
WordOperations
.
moveWordLeft
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
,
inSelectionMode
,
wordNavigationType
))
);
}
private
static
_moveRight
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
noOfColumns
:
number
=
1
,
ctx
:
IOneCursorOperationContext
):
boolean
{
return
this
.
_applyMoveOperationResult
(
cursor
,
ctx
,
...
...
@@ -630,13 +623,6 @@ export class OneCursorOp {
);
}
public
static
moveWordRight
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
wordNavigationType
:
WordNavigationType
,
ctx
:
IOneCursorOperationContext
):
boolean
{
return
this
.
_applyMoveOperationResult
(
cursor
,
ctx
,
this
.
_fromModelCursorState
(
cursor
,
WordOperations
.
moveWordRight
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
,
inSelectionMode
,
wordNavigationType
))
);
}
private
static
_moveDown
(
cursor
:
OneCursor
,
moveArguments
:
CursorMoveArguments
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
linesCount
=
(
moveArguments
.
isPaged
?
(
moveArguments
.
pageSize
||
cursor
.
config
.
pageSize
)
:
moveArguments
.
value
)
||
1
;
if
(
editorCommon
.
CursorMoveByUnit
.
WrappedLine
===
moveArguments
.
by
)
{
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
20f903c0
...
...
@@ -4381,25 +4381,9 @@ export var Handler = {
CursorLeft
:
'
cursorLeft
'
,
CursorLeftSelect
:
'
cursorLeftSelect
'
,
CursorWordLeft
:
'
cursorWordLeft
'
,
CursorWordStartLeft
:
'
cursorWordStartLeft
'
,
CursorWordEndLeft
:
'
cursorWordEndLeft
'
,
CursorWordLeftSelect
:
'
cursorWordLeftSelect
'
,
CursorWordStartLeftSelect
:
'
cursorWordStartLeftSelect
'
,
CursorWordEndLeftSelect
:
'
cursorWordEndLeftSelect
'
,
CursorRight
:
'
cursorRight
'
,
CursorRightSelect
:
'
cursorRightSelect
'
,
CursorWordRight
:
'
cursorWordRight
'
,
CursorWordStartRight
:
'
cursorWordStartRight
'
,
CursorWordEndRight
:
'
cursorWordEndRight
'
,
CursorWordRightSelect
:
'
cursorWordRightSelect
'
,
CursorWordStartRightSelect
:
'
cursorWordStartRightSelect
'
,
CursorWordEndRightSelect
:
'
cursorWordEndRightSelect
'
,
CursorUp
:
'
cursorUp
'
,
CursorUpSelect
:
'
cursorUpSelect
'
,
CursorDown
:
'
cursorDown
'
,
...
...
src/vs/editor/common/editorCommonExtensions.ts
浏览文件 @
20f903c0
...
...
@@ -95,6 +95,10 @@ export function editorAction(ctor: { new (): EditorAction; }): void {
CommonEditorRegistry
.
registerEditorAction
(
new
ctor
());
}
export
function
editorCommand
(
ctor
:
{
new
():
ConfigEditorCommand
}):
void
{
CommonEditorRegistry
.
registerEditorCommand
(
new
ctor
());
}
export
function
commonEditorContribution
(
ctor
:
editorCommon
.
ICommonEditorContributionCtor
):
void
{
EditorContributionRegistry
.
INSTANCE
.
registerEditorContribution
(
ctor
);
}
...
...
src/vs/editor/contrib/wordOperations/common/wordOperations.ts
0 → 100644
浏览文件 @
20f903c0
/*---------------------------------------------------------------------------------------------
* 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
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
EditorContextKeys
,
ICommonCodeEditor
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
editorCommand
,
ServicesAccessor
,
EditorCommand
,
ICommandOptions
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
WordNavigationType
,
WordOperations
,
getMapForWordSeparators
,
WordCharacterClassifier
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
export
interface
MoveWordOptions
extends
ICommandOptions
{
inSelectionMode
:
boolean
;
wordNavigationType
:
WordNavigationType
;
}
export
abstract
class
WordCommand
extends
EditorCommand
{
private
readonly
_inSelectionMode
:
boolean
;
private
readonly
_wordNavigationType
:
WordNavigationType
;
constructor
(
opts
:
MoveWordOptions
)
{
super
(
opts
);
this
.
_inSelectionMode
=
opts
.
inSelectionMode
;
this
.
_wordNavigationType
=
opts
.
wordNavigationType
;
}
public
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
,
args
:
any
):
void
{
const
config
=
editor
.
getConfiguration
();
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
const
model
=
editor
.
getModel
();
const
selections
=
editor
.
getSelections
();
const
result
=
selections
.
map
((
sel
)
=>
{
const
inPosition
=
new
Position
(
sel
.
positionLineNumber
,
sel
.
positionColumn
);
const
outPosition
=
this
.
_move
(
wordSeparators
,
model
,
inPosition
,
this
.
_wordNavigationType
);
return
move
(
sel
,
outPosition
,
this
.
_inSelectionMode
);
});
editor
.
setSelections
(
result
);
}
protected
abstract
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
;
}
export
class
WordLeftCommand
extends
WordCommand
{
protected
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
return
WordOperations
.
moveWordLeft
(
wordSeparators
,
model
,
position
,
wordNavigationType
);
}
}
export
class
WordRightCommand
extends
WordCommand
{
protected
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
return
WordOperations
.
moveWordRight
(
wordSeparators
,
model
,
position
,
wordNavigationType
);
}
}
@
editorCommand
export
class
CursorWordStartLeft
extends
WordLeftCommand
{
constructor
()
{
super
({
inSelectionMode
:
false
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
cursorWordStartLeft
'
,
precondition
:
null
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
LeftArrow
,
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyCode
.
LeftArrow
}
}
});
}
}
@
editorCommand
export
class
CursorWordEndLeft
extends
WordLeftCommand
{
constructor
()
{
super
({
inSelectionMode
:
false
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
cursorWordEndLeft
'
,
precondition
:
null
});
}
}
@
editorCommand
export
class
CursorWordLeft
extends
WordLeftCommand
{
constructor
()
{
super
({
inSelectionMode
:
false
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
cursorWordLeft
'
,
precondition
:
null
});
}
}
@
editorCommand
export
class
CursorWordStartLeftSelect
extends
WordLeftCommand
{
constructor
()
{
super
({
inSelectionMode
:
true
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
cursorWordStartLeftSelect
'
,
precondition
:
null
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
LeftArrow
,
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyMod
.
Shift
|
KeyCode
.
LeftArrow
}
}
});
}
}
@
editorCommand
export
class
CursorWordEndLeftSelect
extends
WordLeftCommand
{
constructor
()
{
super
({
inSelectionMode
:
true
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
cursorWordEndLeftSelect
'
,
precondition
:
null
});
}
}
@
editorCommand
export
class
CursorWordLeftSelect
extends
WordLeftCommand
{
constructor
()
{
super
({
inSelectionMode
:
true
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
cursorWordLeftSelect
'
,
precondition
:
null
});
}
}
@
editorCommand
export
class
CursorWordStartRight
extends
WordRightCommand
{
constructor
()
{
super
({
inSelectionMode
:
false
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
cursorWordStartRight
'
,
precondition
:
null
});
}
}
@
editorCommand
export
class
CursorWordEndRight
extends
WordRightCommand
{
constructor
()
{
super
({
inSelectionMode
:
false
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
cursorWordEndRight
'
,
precondition
:
null
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
RightArrow
,
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyCode
.
RightArrow
}
}
});
}
}
@
editorCommand
export
class
CursorWordRight
extends
WordRightCommand
{
constructor
()
{
super
({
inSelectionMode
:
false
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
cursorWordRight
'
,
precondition
:
null
});
}
}
@
editorCommand
export
class
CursorWordStartRightSelect
extends
WordRightCommand
{
constructor
()
{
super
({
inSelectionMode
:
true
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
cursorWordStartRightSelect
'
,
precondition
:
null
});
}
}
@
editorCommand
export
class
CursorWordEndRightSelect
extends
WordRightCommand
{
constructor
()
{
super
({
inSelectionMode
:
true
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
cursorWordEndRightSelect
'
,
precondition
:
null
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
RightArrow
,
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyMod
.
Shift
|
KeyCode
.
RightArrow
}
}
});
}
}
@
editorCommand
export
class
CursorWordRightSelect
extends
WordRightCommand
{
constructor
()
{
super
({
inSelectionMode
:
true
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
cursorWordRightSelect
'
,
precondition
:
null
});
}
}
function
move
(
from
:
Selection
,
to
:
Position
,
inSelectionMode
:
boolean
):
Selection
{
if
(
inSelectionMode
)
{
// move just position
return
new
Selection
(
from
.
selectionStartLineNumber
,
from
.
selectionStartColumn
,
to
.
lineNumber
,
to
.
column
);
}
else
{
// move everything
return
new
Selection
(
to
.
lineNumber
,
to
.
column
,
to
.
lineNumber
,
to
.
column
);
}
}
src/vs/editor/contrib/wordOperations/test/common/wordOperations.test.ts
0 → 100644
浏览文件 @
20f903c0
/*---------------------------------------------------------------------------------------------
* 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
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
withMockCodeEditor
}
from
'
vs/editor/test/common/mocks/mockCodeEditor
'
;
import
{
CursorWordLeft
,
CursorWordLeftSelect
,
CursorWordStartLeft
,
CursorWordEndLeft
,
CursorWordStartLeftSelect
,
CursorWordEndLeftSelect
,
CursorWordStartRight
,
CursorWordEndRight
,
CursorWordRight
,
CursorWordStartRightSelect
,
CursorWordEndRightSelect
,
CursorWordRightSelect
}
from
'
vs/editor/contrib/wordOperations/common/wordOperations
'
;
import
{
EditorCommand
}
from
'
vs/editor/common/config/config
'
;
suite
(
'
WordOperations
'
,
()
=>
{
const
_cursorWordStartLeft
=
new
CursorWordStartLeft
();
const
_cursorWordEndLeft
=
new
CursorWordEndLeft
();
const
_cursorWordLeft
=
new
CursorWordLeft
();
const
_cursorWordStartLeftSelect
=
new
CursorWordStartLeftSelect
();
const
_cursorWordEndLeftSelect
=
new
CursorWordEndLeftSelect
();
const
_cursorWordLeftSelect
=
new
CursorWordLeftSelect
();
const
_cursorWordStartRight
=
new
CursorWordStartRight
();
const
_cursorWordEndRight
=
new
CursorWordEndRight
();
const
_cursorWordRight
=
new
CursorWordRight
();
const
_cursorWordStartRightSelect
=
new
CursorWordStartRightSelect
();
const
_cursorWordEndRightSelect
=
new
CursorWordEndRightSelect
();
const
_cursorWordRightSelect
=
new
CursorWordRightSelect
();
function
runEditorCommand
(
editor
:
ICommonCodeEditor
,
command
:
EditorCommand
):
void
{
command
.
runEditorCommand
(
null
,
editor
,
null
);
}
function
moveWordLeft
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordLeftSelect
:
_cursorWordLeft
);
}
function
moveWordStartLeft
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordStartLeftSelect
:
_cursorWordStartLeft
);
}
function
moveWordEndLeft
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordEndLeftSelect
:
_cursorWordEndLeft
);
}
function
moveWordRight
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordRightSelect
:
_cursorWordRight
);
}
function
moveWordEndRight
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordEndRightSelect
:
_cursorWordEndRight
);
}
function
moveWordStartRight
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordStartRightSelect
:
_cursorWordStartRight
);
}
test
(
'
move word left
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
5
,
2
));
const
expectedStops
=
[
[
5
,
1
],
[
4
,
1
],
[
3
,
11
],
[
3
,
5
],
[
3
,
1
],
[
2
,
12
],
[
2
,
5
],
[
2
,
2
],
[
2
,
1
],
[
1
,
15
],
[
1
,
9
],
[
1
,
6
],
[
1
,
1
],
[
1
,
1
],
];
let
actualStops
:
number
[][]
=
[];
for
(
let
i
=
0
;
i
<
expectedStops
.
length
;
i
++
)
{
moveWordLeft
(
editor
);
const
pos
=
editor
.
getPosition
();
actualStops
.
push
([
pos
.
lineNumber
,
pos
.
column
]);
}
assert
.
deepEqual
(
actualStops
,
expectedStops
);
});
});
test
(
'
move word left selection
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
5
,
2
));
moveWordLeft
(
editor
,
true
);
assert
.
deepEqual
(
editor
.
getSelection
(),
new
Selection
(
5
,
2
,
5
,
1
));
});
});
test
(
'
issue #832: moveWordLeft
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
50
));
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
001
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
002
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
003
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
004
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
005
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
006
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
007
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
009
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
010
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
011
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
012
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
013
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
014
'
);
moveWordLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
'
.
length
+
1
,
'
015
'
);
});
});
test
(
'
moveWordStartLeft
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
50
));
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
001
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
002
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
003
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
004
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
005
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
006
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
007
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
009
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
010
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
011
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
012
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
013
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
014
'
);
moveWordStartLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
'
.
length
+
1
,
'
015
'
);
});
});
test
(
'
moveWordEndLeft
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
50
));
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
001
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
002
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
003
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
004
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
005
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
006
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
007
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
008
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
009
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
010
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
011
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
012
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
013
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
014
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
015
'
);
moveWordEndLeft
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
''
.
length
+
1
,
'
016
'
);
});
});
test
(
'
move word right
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
1
));
let
expectedStops
=
[
[
1
,
8
],
[
1
,
14
],
[
1
,
19
],
[
1
,
21
],
[
2
,
4
],
[
2
,
11
],
[
2
,
16
],
[
3
,
10
],
[
3
,
17
],
[
4
,
1
],
[
5
,
2
],
[
5
,
2
],
];
let
actualStops
:
number
[][]
=
[];
for
(
let
i
=
0
;
i
<
expectedStops
.
length
;
i
++
)
{
moveWordRight
(
editor
);
let
pos
=
editor
.
getPosition
();
actualStops
.
push
([
pos
.
lineNumber
,
pos
.
column
]);
}
assert
.
deepEqual
(
actualStops
,
expectedStops
);
});
});
test
(
'
move word right selection
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
1
));
moveWordRight
(
editor
,
true
);
assert
.
deepEqual
(
editor
.
getSelection
(),
new
Selection
(
1
,
1
,
1
,
8
));
});
});
test
(
'
issue #832: moveWordRight
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
1
));
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
001
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
003
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
004
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
005
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
006
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
007
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
009
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
010
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
011
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
012
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
013
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
014
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
015
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
moveWordRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
});
});
test
(
'
moveWordEndRight
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
1
));
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
001
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
003
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
004
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
005
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
006
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
007
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
009
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
010
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
011
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
012
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
013
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
014
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
015
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
moveWordEndRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
});
});
test
(
'
moveWordStartRight
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
1
));
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
'
.
length
+
1
,
'
001
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
002
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
003
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
004
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
005
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
006
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
007
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
009
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
010
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
011
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
012
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
013
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
014
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
015
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
});
});
});
src/vs/editor/test/common/controller/cursor.test.ts
浏览文件 @
20f903c0
...
...
@@ -40,30 +40,10 @@ function moveLeft(cursor: Cursor, inSelectionMode: boolean = false) {
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorLeftSelect
:
H
.
CursorLeft
);
}
function
moveWordLeft
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorWordLeftSelect
:
H
.
CursorWordLeft
);
}
function
moveWordStartLeft
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorWordStartLeftSelect
:
H
.
CursorWordStartLeft
);
}
function
moveWordEndLeft
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorWordEndLeftSelect
:
H
.
CursorWordEndLeft
);
}
function
moveRight
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorRightSelect
:
H
.
CursorRight
);
}
function
moveWordRight
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorWordRightSelect
:
H
.
CursorWordRight
);
}
function
moveWordEndRight
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorWordEndRightSelect
:
H
.
CursorWordEndRight
);
}
function
moveWordStartRight
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorWordStartRightSelect
:
H
.
CursorWordStartRight
);
}
function
moveDown
(
cursor
:
Cursor
,
linesCount
:
number
,
inSelectionMode
:
boolean
=
false
)
{
if
(
linesCount
===
1
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorDownSelect
:
H
.
CursorDown
);
...
...
@@ -248,44 +228,6 @@ suite('Editor Controller - Cursor', () => {
assertCursor
(
thisCursor
,
new
Selection
(
2
,
1
,
1
,
21
));
});
// --------- move word left
test
(
'
move word left
'
,
()
=>
{
moveTo
(
thisCursor
,
5
,
2
);
let
expectedStops
=
[
[
5
,
1
],
[
4
,
1
],
[
3
,
11
],
[
3
,
5
],
[
3
,
1
],
[
2
,
12
],
[
2
,
5
],
[
2
,
2
],
[
2
,
1
],
[
1
,
15
],
[
1
,
9
],
[
1
,
6
],
[
1
,
1
],
[
1
,
1
],
];
let
actualStops
:
number
[][]
=
[];
for
(
let
i
=
0
;
i
<
expectedStops
.
length
;
i
++
)
{
moveWordLeft
(
thisCursor
);
let
pos
=
thisCursor
.
getPosition
();
actualStops
.
push
([
pos
.
lineNumber
,
pos
.
column
]);
}
assert
.
deepEqual
(
actualStops
,
expectedStops
);
});
test
(
'
move word left selection
'
,
()
=>
{
moveTo
(
thisCursor
,
5
,
2
);
assertCursor
(
thisCursor
,
new
Position
(
5
,
2
));
moveWordLeft
(
thisCursor
,
true
);
assertCursor
(
thisCursor
,
new
Selection
(
5
,
2
,
5
,
1
));
});
// --------- move right
test
(
'
move right on bottom right position
'
,
()
=>
{
...
...
@@ -323,41 +265,6 @@ suite('Editor Controller - Cursor', () => {
assertCursor
(
thisCursor
,
new
Selection
(
1
,
21
,
2
,
1
));
});
// --------- move word right
test
(
'
move word right
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
1
);
let
expectedStops
=
[
[
1
,
8
],
[
1
,
14
],
[
1
,
19
],
[
1
,
21
],
[
2
,
4
],
[
2
,
11
],
[
2
,
16
],
[
3
,
10
],
[
3
,
17
],
[
4
,
1
],
[
5
,
2
],
[
5
,
2
],
];
let
actualStops
:
number
[][]
=
[];
for
(
let
i
=
0
;
i
<
expectedStops
.
length
;
i
++
)
{
moveWordRight
(
thisCursor
);
let
pos
=
thisCursor
.
getPosition
();
actualStops
.
push
([
pos
.
lineNumber
,
pos
.
column
]);
}
assert
.
deepEqual
(
actualStops
,
expectedStops
);
});
test
(
'
move word right selection
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
1
);
assertCursor
(
thisCursor
,
new
Position
(
1
,
1
));
moveWordRight
(
thisCursor
,
true
);
assertCursor
(
thisCursor
,
new
Selection
(
1
,
1
,
1
,
8
));
});
// --------- move down
test
(
'
move down
'
,
()
=>
{
...
...
@@ -1962,168 +1869,6 @@ suite('Editor Controller - Regression tests', () => {
});
});
test
(
'
issue #832: moveWordLeft
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
50
,
false
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
001
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
002
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
003
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
004
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
005
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
006
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
007
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
009
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
010
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
011
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
012
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
013
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
014
'
);
moveWordLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
'
.
length
+
1
,
'
015
'
);
});
});
test
(
'
moveWordStartLeft
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
50
,
false
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
001
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
002
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
003
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
004
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
005
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
006
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
007
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
009
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
010
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
011
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
012
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
013
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
014
'
);
moveWordStartLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
'
.
length
+
1
,
'
015
'
);
});
});
test
(
'
moveWordEndLeft
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
50
,
false
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
001
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
002
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
003
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
004
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
005
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
006
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
007
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
008
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
009
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
010
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
011
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
012
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
013
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
014
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
015
'
);
moveWordEndLeft
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
''
.
length
+
1
,
'
016
'
);
});
});
test
(
'
issue #832: moveWordRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
1
,
false
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
001
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
003
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
004
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
005
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
006
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
007
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
009
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
010
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
011
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
012
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
013
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
014
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
015
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
moveWordRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
});
});
test
(
'
moveWordEndRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
1
,
false
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
001
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
003
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
004
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
005
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
006
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
007
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
009
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
010
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
011
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
012
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
013
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
014
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
015
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
moveWordEndRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
});
});
test
(
'
moveWordStartRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some more text a+= 3 +5-3 + 7 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
1
,
false
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
'
.
length
+
1
,
'
001
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/*
'
.
length
+
1
,
'
002
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just
'
.
length
+
1
,
'
003
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some
'
.
length
+
1
,
'
004
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more
'
.
length
+
1
,
'
005
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text
'
.
length
+
1
,
'
006
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a
'
.
length
+
1
,
'
007
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+=
'
.
length
+
1
,
'
008
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3
'
.
length
+
1
,
'
009
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +
'
.
length
+
1
,
'
010
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5
'
.
length
+
1
,
'
011
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-
'
.
length
+
1
,
'
012
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3
'
.
length
+
1
,
'
013
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 +
'
.
length
+
1
,
'
014
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7
'
.
length
+
1
,
'
015
'
);
moveWordStartRight
(
cursor
);
assert
.
equal
(
cursor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
});
});
test
(
'
issue #832: word right
'
,
()
=>
{
usingCursor
({
...
...
src/vs/monaco.d.ts
浏览文件 @
20f903c0
...
...
@@ -3450,20 +3450,8 @@ declare module monaco.editor {
ExecuteCommands
:
string
;
CursorLeft
:
string
;
CursorLeftSelect
:
string
;
CursorWordLeft
:
string
;
CursorWordStartLeft
:
string
;
CursorWordEndLeft
:
string
;
CursorWordLeftSelect
:
string
;
CursorWordStartLeftSelect
:
string
;
CursorWordEndLeftSelect
:
string
;
CursorRight
:
string
;
CursorRightSelect
:
string
;
CursorWordRight
:
string
;
CursorWordStartRight
:
string
;
CursorWordEndRight
:
string
;
CursorWordRightSelect
:
string
;
CursorWordStartRightSelect
:
string
;
CursorWordEndRightSelect
:
string
;
CursorUp
:
string
;
CursorUpSelect
:
string
;
CursorDown
:
string
;
...
...
src/vs/workbench/parts/debug/browser/debugEditorActions.ts
浏览文件 @
20f903c0
...
...
@@ -268,7 +268,7 @@ class CloseBreakpointWidgetCommand extends EditorCommand {
});
}
p
rotected
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
,
args
:
any
):
void
{
p
ublic
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
,
args
:
any
):
void
{
return
editor
.
getContribution
<
IDebugEditorContribution
>
(
EDITOR_CONTRIBUTION_ID
).
closeBreakpointWidget
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录