Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
386f9929
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,发现更多精彩内容 >>
提交
386f9929
编写于
3月 26, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract delete word commands outside of core
上级
20f903c0
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
532 addition
and
380 deletion
+532
-380
src/vs/editor/common/config/config.ts
src/vs/editor/common/config/config.ts
+0
-8
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+0
-18
src/vs/editor/common/controller/cursorWordOperations.ts
src/vs/editor/common/controller/cursorWordOperations.ts
+3
-28
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+0
-8
src/vs/editor/contrib/wordOperations/common/wordOperations.ts
...vs/editor/contrib/wordOperations/common/wordOperations.ts
+159
-21
src/vs/editor/contrib/wordOperations/test/common/wordOperations.test.ts
...contrib/wordOperations/test/common/wordOperations.test.ts
+370
-1
src/vs/editor/test/common/controller/cursor.test.ts
src/vs/editor/test/common/controller/cursor.test.ts
+0
-290
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+0
-6
未找到文件。
src/vs/editor/common/config/config.ts
浏览文件 @
386f9929
...
@@ -602,14 +602,6 @@ registerCommand(new CoreCommand({
...
@@ -602,14 +602,6 @@ registerCommand(new CoreCommand({
}
}
}));
}));
registerCommand
(
new
WordCommand
(
H
.
DeleteWordLeft
,
false
,
KeyCode
.
Backspace
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
DeleteWordStartLeft
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
DeleteWordEndLeft
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
WordCommand
(
H
.
DeleteWordRight
,
false
,
KeyCode
.
Delete
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
DeleteWordStartRight
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
UnboundCoreCommand
(
H
.
DeleteWordEndRight
,
EditorContextKeys
.
Writable
));
registerCommand
(
new
CoreCommand
({
registerCommand
(
new
CoreCommand
({
id
:
H
.
CancelSelection
,
id
:
H
.
CancelSelection
,
precondition
:
EditorContextKeys
.
HasNonEmptySelection
,
precondition
:
EditorContextKeys
.
HasNonEmptySelection
,
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
386f9929
...
@@ -18,7 +18,6 @@ import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
...
@@ -18,7 +18,6 @@ import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
CursorColumns
,
EditOperationResult
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorColumns
,
EditOperationResult
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
WordOperations
,
WordNavigationType
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
import
{
ColumnSelection
,
IColumnSelectResult
}
from
'
vs/editor/common/controller/cursorColumnSelection
'
;
import
{
ColumnSelection
,
IColumnSelectResult
}
from
'
vs/editor/common/controller/cursorColumnSelection
'
;
import
{
DeleteOperations
}
from
'
vs/editor/common/controller/cursorDeleteOperations
'
;
import
{
DeleteOperations
}
from
'
vs/editor/common/controller/cursorDeleteOperations
'
;
import
{
TypeOperations
}
from
'
vs/editor/common/controller/cursorTypeOperations
'
;
import
{
TypeOperations
}
from
'
vs/editor/common/controller/cursorTypeOperations
'
;
...
@@ -957,17 +956,8 @@ export class Cursor extends EventEmitter {
...
@@ -957,17 +956,8 @@ export class Cursor extends EventEmitter {
this
.
_handlers
[
H
.
ScrollPageDown
]
=
(
ctx
)
=>
this
.
_scrollDown
(
true
,
ctx
);
this
.
_handlers
[
H
.
ScrollPageDown
]
=
(
ctx
)
=>
this
.
_scrollDown
(
true
,
ctx
);
this
.
_handlers
[
H
.
DeleteLeft
]
=
(
ctx
)
=>
this
.
_deleteLeft
(
ctx
);
this
.
_handlers
[
H
.
DeleteLeft
]
=
(
ctx
)
=>
this
.
_deleteLeft
(
ctx
);
this
.
_handlers
[
H
.
DeleteWordLeft
]
=
(
ctx
)
=>
this
.
_deleteWordLeft
(
true
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
DeleteWordStartLeft
]
=
(
ctx
)
=>
this
.
_deleteWordLeft
(
false
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
DeleteWordEndLeft
]
=
(
ctx
)
=>
this
.
_deleteWordLeft
(
false
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
DeleteRight
]
=
(
ctx
)
=>
this
.
_deleteRight
(
ctx
);
this
.
_handlers
[
H
.
DeleteRight
]
=
(
ctx
)
=>
this
.
_deleteRight
(
ctx
);
this
.
_handlers
[
H
.
DeleteWordRight
]
=
(
ctx
)
=>
this
.
_deleteWordRight
(
true
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
DeleteWordStartRight
]
=
(
ctx
)
=>
this
.
_deleteWordRight
(
false
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
DeleteWordEndRight
]
=
(
ctx
)
=>
this
.
_deleteWordRight
(
false
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
Cut
]
=
(
ctx
)
=>
this
.
_cut
(
ctx
);
this
.
_handlers
[
H
.
Cut
]
=
(
ctx
)
=>
this
.
_cut
(
ctx
);
this
.
_handlers
[
H
.
ExpandLineSelection
]
=
(
ctx
)
=>
this
.
_expandLineSelection
(
ctx
);
this
.
_handlers
[
H
.
ExpandLineSelection
]
=
(
ctx
)
=>
this
.
_expandLineSelection
(
ctx
);
...
@@ -1462,18 +1452,10 @@ export class Cursor extends EventEmitter {
...
@@ -1462,18 +1452,10 @@ export class Cursor extends EventEmitter {
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
deleteLeft
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
));
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
deleteLeft
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
));
}
}
private
_deleteWordLeft
(
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
,
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
WordOperations
.
deleteWordLeft
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
,
whitespaceHeuristics
,
wordNavigationType
));
}
private
_deleteRight
(
ctx
:
IMultipleCursorOperationContext
):
boolean
{
private
_deleteRight
(
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
deleteRight
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
));
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
deleteRight
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
));
}
}
private
_deleteWordRight
(
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
,
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
WordOperations
.
deleteWordRight
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
,
whitespaceHeuristics
,
wordNavigationType
));
}
private
_cut
(
ctx
:
IMultipleCursorOperationContext
):
boolean
{
private
_cut
(
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
cut
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
,
this
.
enableEmptySelectionClipboard
));
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
cut
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
,
this
.
enableEmptySelectionClipboard
));
}
}
...
...
src/vs/editor/common/controller/cursorWordOperations.ts
浏览文件 @
386f9929
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
'
use strict
'
;
import
{
SingleCursorState
,
EditOperationResult
,
CursorConfiguration
,
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
SingleCursorState
,
CursorConfiguration
,
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
CharacterClassifier
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
CharacterClassifier
}
from
'
vs/editor/common/core/characterClassifier
'
;
...
@@ -13,7 +13,6 @@ import { CursorChangeReason } from 'vs/editor/common/editorCommon';
...
@@ -13,7 +13,6 @@ import { CursorChangeReason } from 'vs/editor/common/editorCommon';
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ReplaceCommand
}
from
'
vs/editor/common/commands/replaceCommand
'
;
export
interface
IFindWordResult
{
export
interface
IFindWordResult
{
/**
/**
...
@@ -268,7 +267,7 @@ export class WordOperations {
...
@@ -268,7 +267,7 @@ export class WordOperations {
return
null
;
return
null
;
}
}
p
rivate
static
_deleteWordLeft
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
selection
:
Selection
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
Range
{
p
ublic
static
_deleteWordLeft
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
selection
:
Selection
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
Range
{
if
(
!
selection
.
isEmpty
())
{
if
(
!
selection
.
isEmpty
())
{
return
selection
;
return
selection
;
}
}
...
@@ -332,18 +331,6 @@ export class WordOperations {
...
@@ -332,18 +331,6 @@ export class WordOperations {
return
new
Range
(
lineNumber
,
column
,
position
.
lineNumber
,
position
.
column
);
return
new
Range
(
lineNumber
,
column
,
position
.
lineNumber
,
position
.
column
);
}
}
public
static
deleteWordLeft
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
EditOperationResult
{
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
const
deleteRange
=
this
.
_deleteWordLeft
(
wordSeparators
,
model
,
cursor
.
selection
,
whitespaceHeuristics
,
wordNavigationType
);
if
(
!
deleteRange
)
{
return
null
;
}
return
new
EditOperationResult
(
new
ReplaceCommand
(
deleteRange
,
''
),
{
shouldPushStackElementBefore
:
(
deleteRange
.
startLineNumber
!==
deleteRange
.
endLineNumber
),
shouldPushStackElementAfter
:
false
});
}
private
static
_findFirstNonWhitespaceChar
(
str
:
string
,
startIndex
:
number
):
number
{
private
static
_findFirstNonWhitespaceChar
(
str
:
string
,
startIndex
:
number
):
number
{
let
len
=
str
.
length
;
let
len
=
str
.
length
;
for
(
let
chIndex
=
startIndex
;
chIndex
<
len
;
chIndex
++
)
{
for
(
let
chIndex
=
startIndex
;
chIndex
<
len
;
chIndex
++
)
{
...
@@ -366,7 +353,7 @@ export class WordOperations {
...
@@ -366,7 +353,7 @@ export class WordOperations {
return
null
;
return
null
;
}
}
p
rivate
static
_deleteWordRight
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
selection
:
Selection
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
Range
{
p
ublic
static
_deleteWordRight
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
selection
:
Selection
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
Range
{
if
(
!
selection
.
isEmpty
())
{
if
(
!
selection
.
isEmpty
())
{
return
selection
;
return
selection
;
}
}
...
@@ -432,18 +419,6 @@ export class WordOperations {
...
@@ -432,18 +419,6 @@ export class WordOperations {
return
new
Range
(
lineNumber
,
column
,
position
.
lineNumber
,
position
.
column
);
return
new
Range
(
lineNumber
,
column
,
position
.
lineNumber
,
position
.
column
);
}
}
public
static
deleteWordRight
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
EditOperationResult
{
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
const
deleteRange
=
this
.
_deleteWordRight
(
wordSeparators
,
model
,
cursor
.
selection
,
whitespaceHeuristics
,
wordNavigationType
);
if
(
!
deleteRange
)
{
return
null
;
}
return
new
EditOperationResult
(
new
ReplaceCommand
(
deleteRange
,
''
),
{
shouldPushStackElementBefore
:
(
deleteRange
.
startLineNumber
!==
deleteRange
.
endLineNumber
),
shouldPushStackElementAfter
:
false
});
}
public
static
word
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
position
:
Position
):
SingleMoveOperationResult
{
public
static
word
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
position
:
Position
):
SingleMoveOperationResult
{
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
let
prevWord
=
WordOperations
.
findPreviousWordOnLine
(
wordSeparators
,
model
,
position
);
let
prevWord
=
WordOperations
.
findPreviousWordOnLine
(
wordSeparators
,
model
,
position
);
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
386f9929
...
@@ -4438,14 +4438,6 @@ export var Handler = {
...
@@ -4438,14 +4438,6 @@ export var Handler = {
DeleteLeft
:
'
deleteLeft
'
,
DeleteLeft
:
'
deleteLeft
'
,
DeleteRight
:
'
deleteRight
'
,
DeleteRight
:
'
deleteRight
'
,
DeleteWordLeft
:
'
deleteWordLeft
'
,
DeleteWordStartLeft
:
'
deleteWordStartLeft
'
,
DeleteWordEndLeft
:
'
deleteWordEndLeft
'
,
DeleteWordRight
:
'
deleteWordRight
'
,
DeleteWordStartRight
:
'
deleteWordStartRight
'
,
DeleteWordEndRight
:
'
deleteWordEndRight
'
,
RemoveSecondaryCursors
:
'
removeSecondaryCursors
'
,
RemoveSecondaryCursors
:
'
removeSecondaryCursors
'
,
CancelSelection
:
'
cancelSelection
'
,
CancelSelection
:
'
cancelSelection
'
,
...
...
src/vs/editor/contrib/wordOperations/common/wordOperations.ts
浏览文件 @
386f9929
...
@@ -10,14 +10,16 @@ import { EditorContextKeys, ICommonCodeEditor, IModel } from 'vs/editor/common/e
...
@@ -10,14 +10,16 @@ import { EditorContextKeys, ICommonCodeEditor, IModel } from 'vs/editor/common/e
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
editorCommand
,
ServicesAccessor
,
EditorCommand
,
ICommandOptions
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
editorCommand
,
ServicesAccessor
,
EditorCommand
,
ICommandOptions
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
WordNavigationType
,
WordOperations
,
getMapForWordSeparators
,
WordCharacterClassifier
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
import
{
WordNavigationType
,
WordOperations
,
getMapForWordSeparators
,
WordCharacterClassifier
}
from
'
vs/editor/common/controller/cursorWordOperations
'
;
import
{
ReplaceCommand
}
from
'
vs/editor/common/commands/replaceCommand
'
;
export
interface
MoveWordOptions
extends
ICommandOptions
{
export
interface
MoveWordOptions
extends
ICommandOptions
{
inSelectionMode
:
boolean
;
inSelectionMode
:
boolean
;
wordNavigationType
:
WordNavigationType
;
wordNavigationType
:
WordNavigationType
;
}
}
export
abstract
class
WordCommand
extends
EditorCommand
{
export
abstract
class
Move
WordCommand
extends
EditorCommand
{
private
readonly
_inSelectionMode
:
boolean
;
private
readonly
_inSelectionMode
:
boolean
;
private
readonly
_wordNavigationType
:
WordNavigationType
;
private
readonly
_wordNavigationType
:
WordNavigationType
;
...
@@ -37,22 +39,42 @@ export abstract class WordCommand extends EditorCommand {
...
@@ -37,22 +39,42 @@ export abstract class WordCommand extends EditorCommand {
const
result
=
selections
.
map
((
sel
)
=>
{
const
result
=
selections
.
map
((
sel
)
=>
{
const
inPosition
=
new
Position
(
sel
.
positionLineNumber
,
sel
.
positionColumn
);
const
inPosition
=
new
Position
(
sel
.
positionLineNumber
,
sel
.
positionColumn
);
const
outPosition
=
this
.
_move
(
wordSeparators
,
model
,
inPosition
,
this
.
_wordNavigationType
);
const
outPosition
=
this
.
_move
(
wordSeparators
,
model
,
inPosition
,
this
.
_wordNavigationType
);
return
move
(
sel
,
outPosition
,
this
.
_inSelectionMode
);
return
this
.
_moveTo
(
sel
,
outPosition
,
this
.
_inSelectionMode
);
});
});
editor
.
setSelections
(
result
);
editor
.
setSelections
(
result
);
}
}
private
_moveTo
(
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
);
}
}
protected
abstract
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
;
protected
abstract
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
;
}
}
export
class
WordLeftCommand
extends
WordCommand
{
export
class
WordLeftCommand
extends
Move
WordCommand
{
protected
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
protected
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
return
WordOperations
.
moveWordLeft
(
wordSeparators
,
model
,
position
,
wordNavigationType
);
return
WordOperations
.
moveWordLeft
(
wordSeparators
,
model
,
position
,
wordNavigationType
);
}
}
}
}
export
class
WordRightCommand
extends
WordCommand
{
export
class
WordRightCommand
extends
Move
WordCommand
{
protected
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
protected
_move
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
return
WordOperations
.
moveWordRight
(
wordSeparators
,
model
,
position
,
wordNavigationType
);
return
WordOperations
.
moveWordRight
(
wordSeparators
,
model
,
position
,
wordNavigationType
);
}
}
...
@@ -222,22 +244,138 @@ export class CursorWordRightSelect extends WordRightCommand {
...
@@ -222,22 +244,138 @@ export class CursorWordRightSelect extends WordRightCommand {
}
}
}
}
function
move
(
from
:
Selection
,
to
:
Position
,
inSelectionMode
:
boolean
):
Selection
{
export
interface
DeleteWordOptions
extends
ICommandOptions
{
if
(
inSelectionMode
)
{
whitespaceHeuristics
:
boolean
;
// move just position
wordNavigationType
:
WordNavigationType
;
return
new
Selection
(
}
from
.
selectionStartLineNumber
,
from
.
selectionStartColumn
,
export
abstract
class
DeleteWordCommand
extends
EditorCommand
{
to
.
lineNumber
,
private
readonly
_whitespaceHeuristics
:
boolean
;
to
.
column
private
readonly
_wordNavigationType
:
WordNavigationType
;
);
}
else
{
constructor
(
opts
:
DeleteWordOptions
)
{
// move everything
super
(
opts
);
return
new
Selection
(
this
.
_whitespaceHeuristics
=
opts
.
whitespaceHeuristics
;
to
.
lineNumber
,
this
.
_wordNavigationType
=
opts
.
wordNavigationType
;
to
.
column
,
}
to
.
lineNumber
,
to
.
column
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
commands
=
selections
.
map
((
sel
)
=>
{
const
deleteRange
=
this
.
_delete
(
wordSeparators
,
model
,
sel
,
this
.
_whitespaceHeuristics
,
this
.
_wordNavigationType
);
return
new
ReplaceCommand
(
deleteRange
,
''
);
});
editor
.
executeCommands
(
this
.
id
,
commands
);
}
protected
abstract
_delete
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
selection
:
Selection
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
Range
;
}
export
class
DeleteWordLeftCommand
extends
DeleteWordCommand
{
protected
_delete
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
selection
:
Selection
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
Range
{
let
r
=
WordOperations
.
_deleteWordLeft
(
wordSeparators
,
model
,
selection
,
whitespaceHeuristics
,
wordNavigationType
);
if
(
r
)
{
return
r
;
}
return
new
Range
(
1
,
1
,
1
,
1
);
}
}
export
class
DeleteWordRightCommand
extends
DeleteWordCommand
{
protected
_delete
(
wordSeparators
:
WordCharacterClassifier
,
model
:
IModel
,
selection
:
Selection
,
whitespaceHeuristics
:
boolean
,
wordNavigationType
:
WordNavigationType
):
Range
{
let
r
=
WordOperations
.
_deleteWordRight
(
wordSeparators
,
model
,
selection
,
whitespaceHeuristics
,
wordNavigationType
);
if
(
r
)
{
return
r
;
}
const
lineCount
=
model
.
getLineCount
();
const
maxColumn
=
model
.
getLineMaxColumn
(
lineCount
);
return
new
Range
(
lineCount
,
maxColumn
,
lineCount
,
maxColumn
);
}
}
@
editorCommand
export
class
DeleteWordStartLeft
extends
DeleteWordLeftCommand
{
constructor
()
{
super
({
whitespaceHeuristics
:
false
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
deleteWordStartLeft
'
,
precondition
:
EditorContextKeys
.
Writable
});
}
}
@
editorCommand
export
class
DeleteWordEndLeft
extends
DeleteWordLeftCommand
{
constructor
()
{
super
({
whitespaceHeuristics
:
false
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
deleteWordEndLeft
'
,
precondition
:
EditorContextKeys
.
Writable
});
}
}
@
editorCommand
export
class
DeleteWordLeft
extends
DeleteWordLeftCommand
{
constructor
()
{
super
({
whitespaceHeuristics
:
true
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
deleteWordLeft
'
,
precondition
:
EditorContextKeys
.
Writable
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Backspace
,
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyCode
.
Backspace
}
}
});
}
}
@
editorCommand
export
class
DeleteWordStartRight
extends
DeleteWordRightCommand
{
constructor
()
{
super
({
whitespaceHeuristics
:
false
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
id
:
'
deleteWordStartRight
'
,
precondition
:
EditorContextKeys
.
Writable
});
}
}
@
editorCommand
export
class
DeleteWordEndRight
extends
DeleteWordRightCommand
{
constructor
()
{
super
({
whitespaceHeuristics
:
false
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
deleteWordEndRight
'
,
precondition
:
EditorContextKeys
.
Writable
});
}
}
@
editorCommand
export
class
DeleteWordRight
extends
DeleteWordRightCommand
{
constructor
()
{
super
({
whitespaceHeuristics
:
true
,
wordNavigationType
:
WordNavigationType
.
WordEnd
,
id
:
'
deleteWordRight
'
,
precondition
:
EditorContextKeys
.
Writable
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Delete
,
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyCode
.
Delete
}
}
});
}
}
}
}
src/vs/editor/contrib/wordOperations/test/common/wordOperations.test.ts
浏览文件 @
386f9929
...
@@ -13,7 +13,9 @@ import {
...
@@ -13,7 +13,9 @@ import {
CursorWordLeft
,
CursorWordLeftSelect
,
CursorWordStartLeft
,
CursorWordLeft
,
CursorWordLeftSelect
,
CursorWordStartLeft
,
CursorWordEndLeft
,
CursorWordStartLeftSelect
,
CursorWordEndLeftSelect
,
CursorWordEndLeft
,
CursorWordStartLeftSelect
,
CursorWordEndLeftSelect
,
CursorWordStartRight
,
CursorWordEndRight
,
CursorWordRight
,
CursorWordStartRight
,
CursorWordEndRight
,
CursorWordRight
,
CursorWordStartRightSelect
,
CursorWordEndRightSelect
,
CursorWordRightSelect
CursorWordStartRightSelect
,
CursorWordEndRightSelect
,
CursorWordRightSelect
,
DeleteWordLeft
,
DeleteWordStartLeft
,
DeleteWordEndLeft
,
DeleteWordRight
,
DeleteWordStartRight
,
DeleteWordEndRight
}
from
'
vs/editor/contrib/wordOperations/common/wordOperations
'
;
}
from
'
vs/editor/contrib/wordOperations/common/wordOperations
'
;
import
{
EditorCommand
}
from
'
vs/editor/common/config/config
'
;
import
{
EditorCommand
}
from
'
vs/editor/common/config/config
'
;
...
@@ -31,6 +33,12 @@ suite('WordOperations', () => {
...
@@ -31,6 +33,12 @@ suite('WordOperations', () => {
const
_cursorWordStartRightSelect
=
new
CursorWordStartRightSelect
();
const
_cursorWordStartRightSelect
=
new
CursorWordStartRightSelect
();
const
_cursorWordEndRightSelect
=
new
CursorWordEndRightSelect
();
const
_cursorWordEndRightSelect
=
new
CursorWordEndRightSelect
();
const
_cursorWordRightSelect
=
new
CursorWordRightSelect
();
const
_cursorWordRightSelect
=
new
CursorWordRightSelect
();
const
_deleteWordLeft
=
new
DeleteWordLeft
();
const
_deleteWordStartLeft
=
new
DeleteWordStartLeft
();
const
_deleteWordEndLeft
=
new
DeleteWordEndLeft
();
const
_deleteWordRight
=
new
DeleteWordRight
();
const
_deleteWordStartRight
=
new
DeleteWordStartRight
();
const
_deleteWordEndRight
=
new
DeleteWordEndRight
();
function
runEditorCommand
(
editor
:
ICommonCodeEditor
,
command
:
EditorCommand
):
void
{
function
runEditorCommand
(
editor
:
ICommonCodeEditor
,
command
:
EditorCommand
):
void
{
command
.
runEditorCommand
(
null
,
editor
,
null
);
command
.
runEditorCommand
(
null
,
editor
,
null
);
...
@@ -53,6 +61,24 @@ suite('WordOperations', () => {
...
@@ -53,6 +61,24 @@ suite('WordOperations', () => {
function
moveWordStartRight
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
function
moveWordStartRight
(
editor
:
ICommonCodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordStartRightSelect
:
_cursorWordStartRight
);
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordStartRightSelect
:
_cursorWordStartRight
);
}
}
function
deleteWordLeft
(
editor
:
ICommonCodeEditor
):
void
{
runEditorCommand
(
editor
,
_deleteWordLeft
);
}
function
deleteWordStartLeft
(
editor
:
ICommonCodeEditor
):
void
{
runEditorCommand
(
editor
,
_deleteWordStartLeft
);
}
function
deleteWordEndLeft
(
editor
:
ICommonCodeEditor
):
void
{
runEditorCommand
(
editor
,
_deleteWordEndLeft
);
}
function
deleteWordRight
(
editor
:
ICommonCodeEditor
):
void
{
runEditorCommand
(
editor
,
_deleteWordRight
);
}
function
deleteWordStartRight
(
editor
:
ICommonCodeEditor
):
void
{
runEditorCommand
(
editor
,
_deleteWordStartRight
);
}
function
deleteWordEndRight
(
editor
:
ICommonCodeEditor
):
void
{
runEditorCommand
(
editor
,
_deleteWordEndRight
);
}
test
(
'
move word left
'
,
()
=>
{
test
(
'
move word left
'
,
()
=>
{
withMockCodeEditor
([
withMockCodeEditor
([
...
@@ -303,4 +329,347 @@ suite('WordOperations', () => {
...
@@ -303,4 +329,347 @@ suite('WordOperations', () => {
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
moveWordStartRight
(
editor
);
assert
.
equal
(
editor
.
getPosition
().
column
,
'
/* Just some more text a+= 3 +5-3 + 7 */
'
.
length
+
1
,
'
016
'
);
});
});
});
});
test
(
'
delete word left for non-empty selection
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setSelection
(
new
Selection
(
3
,
7
,
3
,
9
));
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
3
),
'
Thd Line🐶
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
3
,
7
));
});
});
test
(
'
delete word left for caret at beginning of document
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
1
));
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
\t
My First Line
\t
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
1
,
1
));
});
});
test
(
'
delete word left for caret at end of whitespace
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
3
,
11
));
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
3
),
'
Line🐶
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
3
,
5
));
});
});
test
(
'
delete word left for caret just behind a word
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
2
,
11
));
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
\t
My Line
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
2
,
5
));
});
});
test
(
'
delete word left for caret inside of a word
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
12
));
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
\t
My st Line
\t
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
1
,
9
));
});
});
test
(
'
delete word right for non-empty selection
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setSelection
(
new
Selection
(
3
,
7
,
3
,
9
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
3
),
'
Thd Line🐶
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
3
,
7
));
});
});
test
(
'
delete word right for caret at end of document
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
5
,
3
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
5
),
'
1
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
5
,
2
));
});
});
test
(
'
delete word right for caret at beggining of whitespace
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
3
,
1
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
3
),
'
Third Line🐶
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
3
,
1
));
});
});
test
(
'
delete word right for caret just before a word
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
2
,
5
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
\t
My Line
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
2
,
5
));
});
});
test
(
'
delete word right for caret inside of a word
'
,
()
=>
{
withMockCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
Third Line🐶
'
,
''
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
11
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
\t
My Fi Line
\t
'
);
assert
.
deepEqual
(
editor
.
getPosition
(),
new
Position
(
1
,
11
));
});
});
test
(
'
issue #832: deleteWordLeft
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some text a+= 3 +5 */
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
37
));
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5 */
'
,
'
001
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5
'
,
'
002
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +
'
,
'
003
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3
'
,
'
004
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+=
'
,
'
005
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a
'
,
'
006
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text
'
,
'
007
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some
'
,
'
008
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just
'
,
'
009
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/*
'
,
'
010
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
011
'
);
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
012
'
);
});
});
test
(
'
deleteWordStartLeft
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some text a+= 3 +5 */
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
37
));
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5
'
,
'
001
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +
'
,
'
002
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3
'
,
'
003
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+=
'
,
'
004
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a
'
,
'
005
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text
'
,
'
006
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some
'
,
'
007
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just
'
,
'
008
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/*
'
,
'
009
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
010
'
);
deleteWordStartLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
011
'
);
});
});
test
(
'
deleteWordEndLeft
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some text a+= 3 +5 */
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
37
));
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5 */
'
,
'
001
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5
'
,
'
002
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +
'
,
'
003
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3
'
,
'
004
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+=
'
,
'
005
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a
'
,
'
006
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text
'
,
'
007
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some
'
,
'
008
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just
'
,
'
009
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/*
'
,
'
010
'
);
deleteWordEndLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
011
'
);
});
});
test
(
'
issue #832: deleteWordRight
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some text a+= 3 +5-3 */
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
1
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5-3 */
'
,
'
001
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Just some text a+= 3 +5-3 */
'
,
'
002
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
some text a+= 3 +5-3 */
'
,
'
003
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
text a+= 3 +5-3 */
'
,
'
004
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
a+= 3 +5-3 */
'
,
'
005
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+= 3 +5-3 */
'
,
'
006
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 +5-3 */
'
,
'
007
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+5-3 */
'
,
'
008
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
5-3 */
'
,
'
009
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
-3 */
'
,
'
010
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 */
'
,
'
011
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
*/
'
,
'
012
'
);
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
013
'
);
});
});
test
(
'
issue #3882: deleteWordRight
'
,
()
=>
{
withMockCodeEditor
([
'
public void Add( int x,
'
,
'
int y )
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
24
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
public void Add( int x,int y )
'
,
'
001
'
);
});
});
test
(
'
issue #3882: deleteWordStartRight
'
,
()
=>
{
withMockCodeEditor
([
'
public void Add( int x,
'
,
'
int y )
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
24
));
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
public void Add( int x,int y )
'
,
'
001
'
);
});
});
test
(
'
issue #3882: deleteWordEndRight
'
,
()
=>
{
withMockCodeEditor
([
'
public void Add( int x,
'
,
'
int y )
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
24
));
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
public void Add( int x,int y )
'
,
'
001
'
);
});
});
test
(
'
deleteWordStartRight
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some text a+= 3 +5-3 */
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
1
));
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5-3 */
'
,
'
001
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Just some text a+= 3 +5-3 */
'
,
'
002
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
some text a+= 3 +5-3 */
'
,
'
003
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
text a+= 3 +5-3 */
'
,
'
004
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
a+= 3 +5-3 */
'
,
'
005
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+= 3 +5-3 */
'
,
'
006
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 +5-3 */
'
,
'
007
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+5-3 */
'
,
'
008
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
5-3 */
'
,
'
009
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
-3 */
'
,
'
010
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 */
'
,
'
011
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
*/
'
,
'
012
'
);
deleteWordStartRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
013
'
);
});
});
test
(
'
deleteWordEndRight
'
,
()
=>
{
withMockCodeEditor
([
'
/* Just some text a+= 3 +5-3 */
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
1
));
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Just some text a+= 3 +5-3 */
'
,
'
001
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
some text a+= 3 +5-3 */
'
,
'
002
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
text a+= 3 +5-3 */
'
,
'
003
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
a+= 3 +5-3 */
'
,
'
004
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+= 3 +5-3 */
'
,
'
005
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 +5-3 */
'
,
'
006
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+5-3 */
'
,
'
007
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
5-3 */
'
,
'
008
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
-3 */
'
,
'
009
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 */
'
,
'
010
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
*/
'
,
'
011
'
);
deleteWordEndRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
012
'
);
});
});
test
(
'
issue #3882 (1): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
withMockCodeEditor
([
'
A line with text.
'
,
'
And another one
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
1
,
18
));
deleteWordRight
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
A line with text.And another one
'
,
'
001
'
);
});
});
test
(
'
issue #3882 (2): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
withMockCodeEditor
([
'
A line with text.
'
,
'
And another one
'
],
{},
(
editor
,
_
)
=>
{
const
model
=
editor
.
getModel
();
editor
.
setPosition
(
new
Position
(
2
,
1
));
deleteWordLeft
(
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
A line with text And another one
'
,
'
001
'
);
});
});
});
});
src/vs/editor/test/common/controller/cursor.test.ts
浏览文件 @
386f9929
...
@@ -76,26 +76,6 @@ function moveToEndOfBuffer(cursor: Cursor, inSelectionMode: boolean = false) {
...
@@ -76,26 +76,6 @@ function moveToEndOfBuffer(cursor: Cursor, inSelectionMode: boolean = false) {
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorBottomSelect
:
H
.
CursorBottom
);
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
CursorBottomSelect
:
H
.
CursorBottom
);
}
}
function
deleteWordLeft
(
cursor
:
Cursor
)
{
cursorCommand
(
cursor
,
H
.
DeleteWordLeft
);
}
function
deleteWordStartLeft
(
cursor
:
Cursor
)
{
cursorCommand
(
cursor
,
H
.
DeleteWordStartLeft
);
}
function
deleteWordEndLeft
(
cursor
:
Cursor
)
{
cursorCommand
(
cursor
,
H
.
DeleteWordEndLeft
);
}
function
deleteWordRight
(
cursor
:
Cursor
)
{
cursorCommand
(
cursor
,
H
.
DeleteWordRight
);
}
function
deleteWordStartRight
(
cursor
:
Cursor
)
{
cursorCommand
(
cursor
,
H
.
DeleteWordStartRight
);
}
function
deleteWordEndRight
(
cursor
:
Cursor
)
{
cursorCommand
(
cursor
,
H
.
DeleteWordEndRight
);
}
function
assertCursor
(
cursor
:
Cursor
,
what
:
Position
|
Selection
|
Selection
[]):
void
{
function
assertCursor
(
cursor
:
Cursor
,
what
:
Position
|
Selection
|
Selection
[]):
void
{
let
selections
:
Selection
[];
let
selections
:
Selection
[];
if
(
what
instanceof
Position
)
{
if
(
what
instanceof
Position
)
{
...
@@ -567,82 +547,6 @@ suite('Editor Controller - Cursor', () => {
...
@@ -567,82 +547,6 @@ suite('Editor Controller - Cursor', () => {
assertCursor
(
thisCursor
,
new
Selection
(
3
,
3
,
5
,
LINE5
.
length
+
1
));
assertCursor
(
thisCursor
,
new
Selection
(
3
,
3
,
5
,
LINE5
.
length
+
1
));
});
});
// --------- delete word left/right
test
(
'
delete word left for non-empty selection
'
,
()
=>
{
moveTo
(
thisCursor
,
3
,
7
);
moveRight
(
thisCursor
,
true
);
moveRight
(
thisCursor
,
true
);
deleteWordLeft
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
3
),
'
Thd Line🐶
'
);
assertCursor
(
thisCursor
,
new
Position
(
3
,
7
));
});
test
(
'
delete word left for caret at beginning of document
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
1
);
deleteWordLeft
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
1
),
'
\t
My First Line
\t
'
);
assertCursor
(
thisCursor
,
new
Position
(
1
,
1
));
});
test
(
'
delete word left for caret at end of whitespace
'
,
()
=>
{
moveTo
(
thisCursor
,
3
,
11
);
deleteWordLeft
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
3
),
'
Line🐶
'
);
assertCursor
(
thisCursor
,
new
Position
(
3
,
5
));
});
test
(
'
delete word left for caret just behind a word
'
,
()
=>
{
moveTo
(
thisCursor
,
2
,
11
);
deleteWordLeft
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
2
),
'
\t
My Line
'
);
assertCursor
(
thisCursor
,
new
Position
(
2
,
5
));
});
test
(
'
delete word left for caret inside of a word
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
12
);
deleteWordLeft
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
1
),
'
\t
My st Line
\t
'
);
assertCursor
(
thisCursor
,
new
Position
(
1
,
9
));
});
test
(
'
delete word right for non-empty selection
'
,
()
=>
{
moveTo
(
thisCursor
,
3
,
7
);
moveRight
(
thisCursor
,
true
);
moveRight
(
thisCursor
,
true
);
deleteWordRight
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
3
),
'
Thd Line🐶
'
);
assertCursor
(
thisCursor
,
new
Position
(
3
,
7
));
});
test
(
'
delete word right for caret at end of document
'
,
()
=>
{
moveTo
(
thisCursor
,
5
,
3
);
deleteWordRight
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
5
),
'
1
'
);
assertCursor
(
thisCursor
,
new
Position
(
5
,
2
));
});
test
(
'
delete word right for caret at beggining of whitespace
'
,
()
=>
{
moveTo
(
thisCursor
,
3
,
1
);
deleteWordRight
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
3
),
'
Third Line🐶
'
);
assertCursor
(
thisCursor
,
new
Position
(
3
,
1
));
});
test
(
'
delete word right for caret just before a word
'
,
()
=>
{
moveTo
(
thisCursor
,
2
,
5
);
deleteWordRight
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
2
),
'
\t
My Line
'
);
assertCursor
(
thisCursor
,
new
Position
(
2
,
5
));
});
test
(
'
delete word right for caret inside of a word
'
,
()
=>
{
moveTo
(
thisCursor
,
1
,
11
);
deleteWordRight
(
thisCursor
);
assert
.
equal
(
thisModel
.
getLineContent
(
1
),
'
\t
My Fi Line
\t
'
);
assertCursor
(
thisCursor
,
new
Position
(
1
,
11
));
});
// --------- misc
// --------- misc
test
(
'
select all
'
,
()
=>
{
test
(
'
select all
'
,
()
=>
{
...
@@ -1699,176 +1603,6 @@ suite('Editor Controller - Regression tests', () => {
...
@@ -1699,176 +1603,6 @@ suite('Editor Controller - Regression tests', () => {
});
});
});
});
test
(
'
issue #832: deleteWordLeft
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some text a+= 3 +5 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
37
,
false
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5 */
'
,
'
001
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5
'
,
'
002
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +
'
,
'
003
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3
'
,
'
004
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+=
'
,
'
005
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a
'
,
'
006
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text
'
,
'
007
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some
'
,
'
008
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just
'
,
'
009
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/*
'
,
'
010
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
011
'
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
012
'
);
});
});
test
(
'
deleteWordStartLeft
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some text a+= 3 +5 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
37
,
false
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5
'
,
'
001
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +
'
,
'
002
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3
'
,
'
003
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+=
'
,
'
004
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a
'
,
'
005
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text
'
,
'
006
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some
'
,
'
007
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just
'
,
'
008
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/*
'
,
'
009
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
010
'
);
deleteWordStartLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
011
'
);
});
});
test
(
'
deleteWordEndLeft
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some text a+= 3 +5 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
37
,
false
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5 */
'
,
'
001
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5
'
,
'
002
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +
'
,
'
003
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3
'
,
'
004
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+=
'
,
'
005
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a
'
,
'
006
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text
'
,
'
007
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some
'
,
'
008
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just
'
,
'
009
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/*
'
,
'
010
'
);
deleteWordEndLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
011
'
);
});
});
test
(
'
issue #832: deleteWordRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some text a+= 3 +5-3 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
1
,
false
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5-3 */
'
,
'
001
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Just some text a+= 3 +5-3 */
'
,
'
002
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
some text a+= 3 +5-3 */
'
,
'
003
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
text a+= 3 +5-3 */
'
,
'
004
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
a+= 3 +5-3 */
'
,
'
005
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+= 3 +5-3 */
'
,
'
006
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 +5-3 */
'
,
'
007
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+5-3 */
'
,
'
008
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
5-3 */
'
,
'
009
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
-3 */
'
,
'
010
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 */
'
,
'
011
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
*/
'
,
'
012
'
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
013
'
);
});
});
test
(
'
issue #3882: deleteWordRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
public void Add( int x,
'
,
'
int y )
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
24
,
false
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
public void Add( int x,int y )
'
,
'
001
'
);
});
});
test
(
'
issue #3882: deleteWordStartRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
public void Add( int x,
'
,
'
int y )
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
24
,
false
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
public void Add( int x,int y )
'
,
'
001
'
);
});
});
test
(
'
issue #3882: deleteWordEndRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
public void Add( int x,
'
,
'
int y )
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
24
,
false
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
public void Add( int x,int y )
'
,
'
001
'
);
});
});
test
(
'
deleteWordStartRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some text a+= 3 +5-3 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
1
,
false
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
/* Just some text a+= 3 +5-3 */
'
,
'
001
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Just some text a+= 3 +5-3 */
'
,
'
002
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
some text a+= 3 +5-3 */
'
,
'
003
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
text a+= 3 +5-3 */
'
,
'
004
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
a+= 3 +5-3 */
'
,
'
005
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+= 3 +5-3 */
'
,
'
006
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 +5-3 */
'
,
'
007
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+5-3 */
'
,
'
008
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
5-3 */
'
,
'
009
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
-3 */
'
,
'
010
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 */
'
,
'
011
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
*/
'
,
'
012
'
);
deleteWordStartRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
''
,
'
013
'
);
});
});
test
(
'
deleteWordEndRight
'
,
()
=>
{
usingCursor
({
text
:
[
'
/* Just some text a+= 3 +5-3 */
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
1
,
false
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Just some text a+= 3 +5-3 */
'
,
'
001
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
some text a+= 3 +5-3 */
'
,
'
002
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
text a+= 3 +5-3 */
'
,
'
003
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
a+= 3 +5-3 */
'
,
'
004
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+= 3 +5-3 */
'
,
'
005
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 +5-3 */
'
,
'
006
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
+5-3 */
'
,
'
007
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
5-3 */
'
,
'
008
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
-3 */
'
,
'
009
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
3 */
'
,
'
010
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
*/
'
,
'
011
'
);
deleteWordEndRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
'
,
'
012
'
);
});
});
test
(
'
issue #832: word right
'
,
()
=>
{
test
(
'
issue #832: word right
'
,
()
=>
{
usingCursor
({
usingCursor
({
...
@@ -1944,30 +1678,6 @@ suite('Editor Controller - Regression tests', () => {
...
@@ -1944,30 +1678,6 @@ suite('Editor Controller - Regression tests', () => {
});
});
});
});
test
(
'
issue #3882 (1): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
usingCursor
({
text
:
[
'
A line with text.
'
,
'
And another one
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
1
,
18
,
false
);
deleteWordRight
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
A line with text.And another one
'
,
'
001
'
);
});
});
test
(
'
issue #3882 (2): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
usingCursor
({
text
:
[
'
A line with text.
'
,
'
And another one
'
],
},
(
model
,
cursor
)
=>
{
moveTo
(
cursor
,
2
,
1
,
false
);
deleteWordLeft
(
cursor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
A line with text And another one
'
,
'
001
'
);
});
});
test
(
'
issue #9675: Undo/Redo adds a stop in between CHN Characters
'
,
()
=>
{
test
(
'
issue #9675: Undo/Redo adds a stop in between CHN Characters
'
,
()
=>
{
usingCursor
({
usingCursor
({
text
:
[
text
:
[
...
...
src/vs/monaco.d.ts
浏览文件 @
386f9929
...
@@ -3494,12 +3494,6 @@ declare module monaco.editor {
...
@@ -3494,12 +3494,6 @@ declare module monaco.editor {
Outdent
:
string
;
Outdent
:
string
;
DeleteLeft
:
string
;
DeleteLeft
:
string
;
DeleteRight
:
string
;
DeleteRight
:
string
;
DeleteWordLeft
:
string
;
DeleteWordStartLeft
:
string
;
DeleteWordEndLeft
:
string
;
DeleteWordRight
:
string
;
DeleteWordStartRight
:
string
;
DeleteWordEndRight
:
string
;
RemoveSecondaryCursors
:
string
;
RemoveSecondaryCursors
:
string
;
CancelSelection
:
string
;
CancelSelection
:
string
;
Cut
:
string
;
Cut
:
string
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录