Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b385bb8f
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,发现更多精彩内容 >>
提交
b385bb8f
编写于
9月 11, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #51119
上级
3c2dbc17
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
122 addition
and
75 deletion
+122
-75
src/vs/editor/common/controller/cursorWordOperations.ts
src/vs/editor/common/controller/cursorWordOperations.ts
+33
-18
src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts
...editor/contrib/wordOperations/test/wordOperations.test.ts
+86
-54
src/vs/editor/contrib/wordOperations/wordOperations.ts
src/vs/editor/contrib/wordOperations/wordOperations.ts
+1
-1
src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts
...ontrib/wordPartOperations/test/wordPartOperations.test.ts
+2
-2
未找到文件。
src/vs/editor/common/controller/cursorWordOperations.ts
浏览文件 @
b385bb8f
...
@@ -39,7 +39,8 @@ const enum WordType {
...
@@ -39,7 +39,8 @@ const enum WordType {
export
const
enum
WordNavigationType
{
export
const
enum
WordNavigationType
{
WordStart
=
0
,
WordStart
=
0
,
WordEnd
=
1
WordStartFast
=
1
,
WordEnd
=
2
}
}
export
class
WordOperations
{
export
class
WordOperations
{
...
@@ -161,9 +162,11 @@ export class WordOperations {
...
@@ -161,9 +162,11 @@ export class WordOperations {
public
static
moveWordLeft
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
public
static
moveWordLeft
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
let
lineNumber
=
position
.
lineNumber
;
let
lineNumber
=
position
.
lineNumber
;
let
column
=
position
.
column
;
let
column
=
position
.
column
;
let
movedToPreviousLine
=
false
;
if
(
column
===
1
)
{
if
(
column
===
1
)
{
if
(
lineNumber
>
1
)
{
if
(
lineNumber
>
1
)
{
movedToPreviousLine
=
true
;
lineNumber
=
lineNumber
-
1
;
lineNumber
=
lineNumber
-
1
;
column
=
model
.
getLineMaxColumn
(
lineNumber
);
column
=
model
.
getLineMaxColumn
(
lineNumber
);
}
}
...
@@ -172,29 +175,41 @@ export class WordOperations {
...
@@ -172,29 +175,41 @@ export class WordOperations {
let
prevWordOnLine
=
WordOperations
.
_findPreviousWordOnLine
(
wordSeparators
,
model
,
new
Position
(
lineNumber
,
column
));
let
prevWordOnLine
=
WordOperations
.
_findPreviousWordOnLine
(
wordSeparators
,
model
,
new
Position
(
lineNumber
,
column
));
if
(
wordNavigationType
===
WordNavigationType
.
WordStart
)
{
if
(
wordNavigationType
===
WordNavigationType
.
WordStart
)
{
if
(
prevWordOnLine
&&
prevWordOnLine
.
wordType
===
WordType
.
Separator
)
{
if
(
prevWordOnLine
.
end
-
prevWordOnLine
.
start
===
1
&&
prevWordOnLine
.
nextCharClass
===
WordCharacterClass
.
Regular
)
{
if
(
prevWordOnLine
&&
!
movedToPreviousLine
)
{
// Skip over a word made up of one single separator and followed by a regular character
// Special case for Visual Studio compatibility:
prevWordOnLine
=
WordOperations
.
_findPreviousWordOnLine
(
wordSeparators
,
model
,
new
Position
(
lineNumber
,
prevWordOnLine
.
start
+
1
));
// when starting in the trim whitespace at the end of a line,
// go to the end of the last word
const
lastWhitespaceColumn
=
model
.
getLineLastNonWhitespaceColumn
(
lineNumber
);
if
(
lastWhitespaceColumn
<
column
)
{
return
new
Position
(
lineNumber
,
prevWordOnLine
.
end
+
1
);
}
}
}
}
if
(
prevWordOnLine
)
{
column
=
prevWordOnLine
.
start
+
1
;
return
new
Position
(
lineNumber
,
prevWordOnLine
?
prevWordOnLine
.
start
+
1
:
1
);
}
else
{
}
column
=
1
;
}
if
(
wordNavigationType
===
WordNavigationType
.
WordStartFast
)
{
}
else
{
if
(
if
(
prevWordOnLine
&&
column
<=
prevWordOnLine
.
end
+
1
)
{
prevWordOnLine
&&
prevWordOnLine
.
wordType
===
WordType
.
Separator
&&
prevWordOnLine
.
end
-
prevWordOnLine
.
start
===
1
&&
prevWordOnLine
.
nextCharClass
===
WordCharacterClass
.
Regular
)
{
// Skip over a word made up of one single separator and followed by a regular character
prevWordOnLine
=
WordOperations
.
_findPreviousWordOnLine
(
wordSeparators
,
model
,
new
Position
(
lineNumber
,
prevWordOnLine
.
start
+
1
));
prevWordOnLine
=
WordOperations
.
_findPreviousWordOnLine
(
wordSeparators
,
model
,
new
Position
(
lineNumber
,
prevWordOnLine
.
start
+
1
));
}
}
if
(
prevWordOnLine
)
{
column
=
prevWordOnLine
.
end
+
1
;
return
new
Position
(
lineNumber
,
prevWordOnLine
?
prevWordOnLine
.
start
+
1
:
1
);
}
else
{
column
=
1
;
}
}
}
return
new
Position
(
lineNumber
,
column
);
// We are stopping at the ending of words
if
(
prevWordOnLine
&&
column
<=
prevWordOnLine
.
end
+
1
)
{
prevWordOnLine
=
WordOperations
.
_findPreviousWordOnLine
(
wordSeparators
,
model
,
new
Position
(
lineNumber
,
prevWordOnLine
.
start
+
1
));
}
return
new
Position
(
lineNumber
,
prevWordOnLine
?
prevWordOnLine
.
end
+
1
:
1
);
}
}
public
static
moveWordRight
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
public
static
moveWordRight
(
wordSeparators
:
WordCharacterClassifier
,
model
:
ICursorSimpleModel
,
position
:
Position
,
wordNavigationType
:
WordNavigationType
):
Position
{
...
...
src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts
浏览文件 @
b385bb8f
...
@@ -44,16 +44,16 @@ suite('WordOperations', () => {
...
@@ -44,16 +44,16 @@ suite('WordOperations', () => {
function
runEditorCommand
(
editor
:
ICodeEditor
,
command
:
EditorCommand
):
void
{
function
runEditorCommand
(
editor
:
ICodeEditor
,
command
:
EditorCommand
):
void
{
command
.
runEditorCommand
(
null
,
editor
,
null
);
command
.
runEditorCommand
(
null
,
editor
,
null
);
}
}
function
move
WordLeft
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
function
cursor
WordLeft
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordLeftSelect
:
_cursorWordLeft
);
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordLeftSelect
:
_cursorWordLeft
);
}
}
function
move
WordStartLeft
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
function
cursor
WordStartLeft
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordStartLeftSelect
:
_cursorWordStartLeft
);
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordStartLeftSelect
:
_cursorWordStartLeft
);
}
}
function
move
WordEndLeft
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
function
cursor
WordEndLeft
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordEndLeftSelect
:
_cursorWordEndLeft
);
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordEndLeftSelect
:
_cursorWordEndLeft
);
}
}
function
move
WordRight
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
function
cursor
WordRight
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordRightSelect
:
_cursorWordRight
);
runEditorCommand
(
editor
,
inSelectionMode
?
_cursorWordRightSelect
:
_cursorWordRight
);
}
}
function
moveWordEndRight
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
function
moveWordEndRight
(
editor
:
ICodeEditor
,
inSelectionMode
:
boolean
=
false
):
void
{
...
@@ -81,7 +81,7 @@ suite('WordOperations', () => {
...
@@ -81,7 +81,7 @@ suite('WordOperations', () => {
runEditorCommand
(
editor
,
_deleteWordEndRight
);
runEditorCommand
(
editor
,
_deleteWordEndRight
);
}
}
test
(
'
move word left
'
,
()
=>
{
test
(
'
cursorWordLeft - simple
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
|
\t
|My |First |Line
\t
'
,
'
|
\t
|My |First |Line
\t
'
,
'
|
\t
|My |Second |Line
'
,
'
|
\t
|My |Second |Line
'
,
...
@@ -93,7 +93,7 @@ suite('WordOperations', () => {
...
@@ -93,7 +93,7 @@ suite('WordOperations', () => {
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1000
,
1000
),
new
Position
(
1000
,
1000
),
ed
=>
move
WordLeft
(
ed
),
ed
=>
cursor
WordLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
);
...
@@ -101,7 +101,7 @@ suite('WordOperations', () => {
...
@@ -101,7 +101,7 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
move word left
selection
'
,
()
=>
{
test
(
'
cursorWordLeft - with
selection
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -110,18 +110,18 @@ suite('WordOperations', () => {
...
@@ -110,18 +110,18 @@ suite('WordOperations', () => {
'
1
'
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
5
,
2
));
editor
.
setPosition
(
new
Position
(
5
,
2
));
move
WordLeft
(
editor
,
true
);
cursor
WordLeft
(
editor
,
true
);
assert
.
deepEqual
(
editor
.
getSelection
(),
new
Selection
(
5
,
2
,
5
,
1
));
assert
.
deepEqual
(
editor
.
getSelection
(),
new
Selection
(
5
,
2
,
5
,
1
));
});
});
});
});
test
(
'
issue #832: moveWordLeft
'
,
()
=>
{
test
(
'
cursorWordLeft - issue #832
'
,
()
=>
{
const
EXPECTED
=
[
'
| |/* |Just |some |more |text |a|+= |3 |+|5-|3 |+ |7 |*/
'
].
join
(
'
\n
'
);
const
EXPECTED
=
[
'
| |/* |Just |some |more |text |a|+= |3 |+|5-|3 |+ |7 |*/
'
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1000
,
1000
),
new
Position
(
1000
,
1000
),
ed
=>
move
WordLeft
(
ed
),
ed
=>
cursor
WordLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
);
...
@@ -129,13 +129,30 @@ suite('WordOperations', () => {
...
@@ -129,13 +129,30 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
moveWordStartLeft
'
,
()
=>
{
test
(
'
cursorWordLeft - issue #48046: Word selection doesn
\'
t work as usual
'
,
()
=>
{
const
EXPECTED
=
[
'
| |/* |Just |some |more |text |a|+= |3 |+|5-|3 |+ |7 |*/
'
].
join
(
'
\n
'
);
const
EXPECTED
=
[
'
|deep.|object.|property
'
,
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
new
Position
(
1
,
21
),
ed
=>
cursorWordLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
test
(
'
cursorWordStartLeft
'
,
()
=>
{
// This is the behaviour observed in Visual Studio, please do not touch test
const
EXPECTED
=
[
'
| |/* |Just |some |more |text |a|+= |3 |+|5|-|3 |+ |7 |*/|
'
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1000
,
1000
),
new
Position
(
1000
,
1000
),
ed
=>
move
WordStartLeft
(
ed
),
ed
=>
cursor
WordStartLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
);
...
@@ -143,13 +160,28 @@ suite('WordOperations', () => {
...
@@ -143,13 +160,28 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
moveWordEndLeft
'
,
()
=>
{
test
(
'
cursorWordStartLeft - issue #51119: regression makes VS compatibility impossible
'
,
()
=>
{
// This is the behaviour observed in Visual Studio, please do not touch test
const
EXPECTED
=
[
'
|this|.|is|.|a|.|test
'
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
new
Position
(
1000
,
1000
),
ed
=>
cursorWordStartLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
test
(
'
cursorWordEndLeft
'
,
()
=>
{
const
EXPECTED
=
[
'
| /*| Just| some| more| text| a|+=| 3| +|5|-|3| +| 7| */|
'
].
join
(
'
\n
'
);
const
EXPECTED
=
[
'
| /*| Just| some| more| text| a|+=| 3| +|5|-|3| +| 7| */|
'
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1000
,
1000
),
new
Position
(
1000
,
1000
),
ed
=>
move
WordEndLeft
(
ed
),
ed
=>
cursor
WordEndLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
);
...
@@ -157,7 +189,7 @@ suite('WordOperations', () => {
...
@@ -157,7 +189,7 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
move word right
'
,
()
=>
{
test
(
'
cursorWordRight - simple
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
\t
My| First| Line|
\t
|
'
,
'
\t
My| First| Line|
\t
|
'
,
'
\t
My| Second| Line|
'
,
'
\t
My| Second| Line|
'
,
...
@@ -169,7 +201,7 @@ suite('WordOperations', () => {
...
@@ -169,7 +201,7 @@ suite('WordOperations', () => {
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1
,
1
),
new
Position
(
1
,
1
),
ed
=>
move
WordRight
(
ed
),
ed
=>
cursor
WordRight
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
5
,
2
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
5
,
2
))
);
);
...
@@ -177,7 +209,7 @@ suite('WordOperations', () => {
...
@@ -177,7 +209,7 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
move word right
selection
'
,
()
=>
{
test
(
'
cursorWordRight -
selection
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -186,12 +218,12 @@ suite('WordOperations', () => {
...
@@ -186,12 +218,12 @@ suite('WordOperations', () => {
'
1
'
,
'
1
'
,
],
{},
(
editor
,
_
)
=>
{
],
{},
(
editor
,
_
)
=>
{
editor
.
setPosition
(
new
Position
(
1
,
1
));
editor
.
setPosition
(
new
Position
(
1
,
1
));
move
WordRight
(
editor
,
true
);
cursor
WordRight
(
editor
,
true
);
assert
.
deepEqual
(
editor
.
getSelection
(),
new
Selection
(
1
,
1
,
1
,
8
));
assert
.
deepEqual
(
editor
.
getSelection
(),
new
Selection
(
1
,
1
,
1
,
8
));
});
});
});
});
test
(
'
issue #832: moveWordRight
'
,
()
=>
{
test
(
'
cursorWordRight - issue #832
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
/*| Just| some| more| text| a|+=| 3| +5|-3| +| 7| */| |
'
,
'
/*| Just| some| more| text| a|+=| 3| +5|-3| +| 7| */| |
'
,
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
...
@@ -199,7 +231,7 @@ suite('WordOperations', () => {
...
@@ -199,7 +231,7 @@ suite('WordOperations', () => {
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1
,
1
),
new
Position
(
1
,
1
),
ed
=>
move
WordRight
(
ed
),
ed
=>
cursor
WordRight
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
50
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
50
))
);
);
...
@@ -207,7 +239,7 @@ suite('WordOperations', () => {
...
@@ -207,7 +239,7 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
issue #41199: moveWordRight
'
,
()
=>
{
test
(
'
cursorWordRight - issue #41199
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
console|.log|(err|)|
'
,
'
console|.log|(err|)|
'
,
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
...
@@ -215,7 +247,7 @@ suite('WordOperations', () => {
...
@@ -215,7 +247,7 @@ suite('WordOperations', () => {
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1
,
1
),
new
Position
(
1
,
1
),
ed
=>
move
WordRight
(
ed
),
ed
=>
cursor
WordRight
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
17
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
17
))
);
);
...
@@ -223,31 +255,32 @@ suite('WordOperations', () => {
...
@@ -223,31 +255,32 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
issue #48046: Word selection doesn
\'
t work as usual
'
,
()
=>
{
test
(
'
moveWordEndRight
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
|deep.|object.|property
'
,
'
/*| Just| some| more| text| a|+=| 3| +5|-3| +| 7| */| |
'
,
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1
,
2
1
),
new
Position
(
1
,
1
),
ed
=>
moveWord
Lef
t
(
ed
),
ed
=>
moveWord
EndRigh
t
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
50
))
);
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
moveWordEndRight
'
,
()
=>
{
test
(
'
moveWordStartRight
'
,
()
=>
{
// This is the behaviour observed in Visual Studio, please do not touch test
const
EXPECTED
=
[
const
EXPECTED
=
[
'
/*| Just| some| more| text| a|+=| 3| +5|-3| +| 7| */|
|
'
,
'
|/* |Just |some |more |text |a|+= |3 |+|5|-|3 |+ |7 |*/
|
'
,
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1
,
1
),
new
Position
(
1
,
1
),
ed
=>
moveWord
End
Right
(
ed
),
ed
=>
moveWord
Start
Right
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
50
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
50
))
);
);
...
@@ -255,23 +288,22 @@ suite('WordOperations', () => {
...
@@ -255,23 +288,22 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
moveWordStartRight
'
,
()
=>
{
test
(
'
issue #51119: cursorWordStartRight regression makes VS compatibility impossible
'
,
()
=>
{
const
EXPECTED
=
[
// This is the behaviour observed in Visual Studio, please do not touch test
'
|/* |Just |some |more |text |a|+= |3 |+|5|-|3 |+ |7 |*/ |
'
,
const
EXPECTED
=
[
'
this|.|is|.|a|.|test|
'
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
new
Position
(
1
,
1
),
new
Position
(
1
,
1
),
ed
=>
moveWordStartRight
(
ed
),
ed
=>
moveWordStartRight
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
50
))
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
15
))
);
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
delete
word l
eft for non-empty selection
'
,
()
=>
{
test
(
'
delete
WordL
eft for non-empty selection
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -287,7 +319,7 @@ suite('WordOperations', () => {
...
@@ -287,7 +319,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word l
eft for cursor at beginning of document
'
,
()
=>
{
test
(
'
delete
WordL
eft for cursor at beginning of document
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -303,7 +335,7 @@ suite('WordOperations', () => {
...
@@ -303,7 +335,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word l
eft for cursor at end of whitespace
'
,
()
=>
{
test
(
'
delete
WordL
eft for cursor at end of whitespace
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -319,7 +351,7 @@ suite('WordOperations', () => {
...
@@ -319,7 +351,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word l
eft for cursor just behind a word
'
,
()
=>
{
test
(
'
delete
WordL
eft for cursor just behind a word
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -335,7 +367,7 @@ suite('WordOperations', () => {
...
@@ -335,7 +367,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word l
eft for cursor inside of a word
'
,
()
=>
{
test
(
'
delete
WordL
eft for cursor inside of a word
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -351,7 +383,7 @@ suite('WordOperations', () => {
...
@@ -351,7 +383,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word r
ight for non-empty selection
'
,
()
=>
{
test
(
'
delete
WordR
ight for non-empty selection
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -367,7 +399,7 @@ suite('WordOperations', () => {
...
@@ -367,7 +399,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word r
ight for cursor at end of document
'
,
()
=>
{
test
(
'
delete
WordR
ight for cursor at end of document
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -383,7 +415,7 @@ suite('WordOperations', () => {
...
@@ -383,7 +415,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word r
ight for cursor at beggining of whitespace
'
,
()
=>
{
test
(
'
delete
WordR
ight for cursor at beggining of whitespace
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -399,7 +431,7 @@ suite('WordOperations', () => {
...
@@ -399,7 +431,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word r
ight for cursor just before a word
'
,
()
=>
{
test
(
'
delete
WordR
ight for cursor just before a word
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -415,7 +447,7 @@ suite('WordOperations', () => {
...
@@ -415,7 +447,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
delete
word r
ight for cursor inside of a word
'
,
()
=>
{
test
(
'
delete
WordR
ight for cursor inside of a word
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
\t
My First Line
\t
'
,
'
\t
My First Line
\t
'
,
'
\t
My Second Line
'
,
'
\t
My Second Line
'
,
...
@@ -431,7 +463,7 @@ suite('WordOperations', () => {
...
@@ -431,7 +463,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
issue #832: deleteWordLeft
'
,
()
=>
{
test
(
'
deleteWordLeft - issue #832
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
| |/* |Just |some |text |a|+= |3 |+|5 |*/|
'
,
'
| |/* |Just |some |text |a|+= |3 |+|5 |*/|
'
,
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
...
@@ -479,7 +511,7 @@ suite('WordOperations', () => {
...
@@ -479,7 +511,7 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
issue #24947
'
,
()
=>
{
test
(
'
deleteWordLeft -
issue #24947
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
{
'
,
'
{
'
,
'
}
'
'
}
'
...
@@ -508,7 +540,7 @@ suite('WordOperations', () => {
...
@@ -508,7 +540,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
issue #832: deleteWordRight
'
,
()
=>
{
test
(
'
deleteWordRight - issue #832
'
,
()
=>
{
const
EXPECTED
=
'
|/*| Just| some| text| a|+=| 3| +|5|-|3| */| |
'
;
const
EXPECTED
=
'
|/*| Just| some| text| a|+=| 3| +|5|-|3| */| |
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
...
@@ -522,7 +554,7 @@ suite('WordOperations', () => {
...
@@ -522,7 +554,7 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
issue #3882: deleteWordRight
'
,
()
=>
{
test
(
'
deleteWordRight - issue #3882
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
public void Add( int x,
'
,
'
public void Add( int x,
'
,
'
int y )
'
'
int y )
'
...
@@ -533,7 +565,7 @@ suite('WordOperations', () => {
...
@@ -533,7 +565,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
issue #3882: deleteWordStartRight
'
,
()
=>
{
test
(
'
deleteWordStartRight - issue #3882
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
public void Add( int x,
'
,
'
public void Add( int x,
'
,
'
int y )
'
'
int y )
'
...
@@ -544,7 +576,7 @@ suite('WordOperations', () => {
...
@@ -544,7 +576,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
issue #3882: deleteWordEndRight
'
,
()
=>
{
test
(
'
deleteWordEndRight - issue #3882
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
public void Add( int x,
'
,
'
public void Add( int x,
'
,
'
int y )
'
'
int y )
'
...
@@ -583,7 +615,7 @@ suite('WordOperations', () => {
...
@@ -583,7 +615,7 @@ suite('WordOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
issue #3882 (1): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
test
(
'
deleteWordRight -
issue #3882 (1): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
A line with text.
'
,
'
A line with text.
'
,
'
And another one
'
'
And another one
'
...
@@ -594,7 +626,7 @@ suite('WordOperations', () => {
...
@@ -594,7 +626,7 @@ suite('WordOperations', () => {
});
});
});
});
test
(
'
issue #3882 (2): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
test
(
'
deleteWordLeft -
issue #3882 (2): Ctrl+Delete removing entire line when used at the end of line
'
,
()
=>
{
withTestCodeEditor
([
withTestCodeEditor
([
'
A line with text.
'
,
'
A line with text.
'
,
'
And another one
'
'
And another one
'
...
...
src/vs/editor/contrib/wordOperations/wordOperations.ts
浏览文件 @
b385bb8f
...
@@ -123,7 +123,7 @@ export class CursorWordLeft extends WordLeftCommand {
...
@@ -123,7 +123,7 @@ export class CursorWordLeft extends WordLeftCommand {
constructor
()
{
constructor
()
{
super
({
super
({
inSelectionMode
:
false
,
inSelectionMode
:
false
,
wordNavigationType
:
WordNavigationType
.
WordStart
,
wordNavigationType
:
WordNavigationType
.
WordStart
Fast
,
id
:
'
cursorWordLeft
'
,
id
:
'
cursorWordLeft
'
,
precondition
:
null
precondition
:
null
});
});
...
...
src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts
浏览文件 @
b385bb8f
...
@@ -52,7 +52,7 @@ suite('WordPartOperations', () => {
...
@@ -52,7 +52,7 @@ suite('WordPartOperations', () => {
});
});
test
(
'
issue #53899: move word part left whitespace
'
,
()
=>
{
test
(
'
issue #53899: move word part left whitespace
'
,
()
=>
{
const
EXPECTED
=
'
|myvar| |=| |
\'
|demonstration| |of| |selection| |with| |space
\'
'
;
const
EXPECTED
=
'
|myvar| |=| |
\'
|demonstration| |of| |selection| |with| |space
|
\'
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
...
@@ -66,7 +66,7 @@ suite('WordPartOperations', () => {
...
@@ -66,7 +66,7 @@ suite('WordPartOperations', () => {
});
});
test
(
'
issue #53899: move word part left underscores
'
,
()
=>
{
test
(
'
issue #53899: move word part left underscores
'
,
()
=>
{
const
EXPECTED
=
'
|myvar| |=| |
\'
|demonstration|_____of| |selection| |with| |space
\'
'
;
const
EXPECTED
=
'
|myvar| |=| |
\'
|demonstration|_____of| |selection| |with| |space
|
\'
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
text
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录