Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
04b42cf0
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
04b42cf0
编写于
9月 05, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #53899
上级
c90755b6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
99 addition
and
6 deletion
+99
-6
src/vs/editor/common/controller/cursorWordOperations.ts
src/vs/editor/common/controller/cursorWordOperations.ts
+37
-4
src/vs/editor/contrib/wordOperations/test/wordTestUtils.ts
src/vs/editor/contrib/wordOperations/test/wordTestUtils.ts
+4
-0
src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts
...ontrib/wordPartOperations/test/wordPartOperations.test.ts
+58
-2
未找到文件。
src/vs/editor/common/controller/cursorWordOperations.ts
浏览文件 @
04b42cf0
...
@@ -468,13 +468,31 @@ export class WordOperations {
...
@@ -468,13 +468,31 @@ export class WordOperations {
export
function
_lastWordPartEnd
(
str
:
string
,
startIndex
:
number
=
str
.
length
-
1
):
number
{
export
function
_lastWordPartEnd
(
str
:
string
,
startIndex
:
number
=
str
.
length
-
1
):
number
{
let
ignoreUpperCase
=
!
strings
.
isLowerAsciiLetter
(
str
.
charCodeAt
(
startIndex
+
1
));
let
ignoreUpperCase
=
!
strings
.
isLowerAsciiLetter
(
str
.
charCodeAt
(
startIndex
+
1
));
for
(
let
i
=
startIndex
;
i
>=
0
;
i
--
)
{
for
(
let
i
=
startIndex
;
i
>=
0
;
i
--
)
{
let
chCode
=
str
.
charCodeAt
(
i
);
const
chCode
=
str
.
charCodeAt
(
i
);
if
(
chCode
===
CharCode
.
Space
||
chCode
===
CharCode
.
Tab
||
(
!
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
))
||
chCode
===
CharCode
.
Underline
)
{
if
(
chCode
===
CharCode
.
Space
||
chCode
===
CharCode
.
Tab
)
{
if
(
i
===
0
)
{
return
0
;
}
const
prevChCode
=
str
.
charCodeAt
(
i
-
1
);
if
(
prevChCode
!==
CharCode
.
Space
&&
prevChCode
!==
CharCode
.
Tab
)
{
return
i
-
1
;
}
}
if
(
!
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
))
{
return
i
-
1
;
return
i
-
1
;
}
}
if
(
ignoreUpperCase
&&
i
<
startIndex
&&
strings
.
isLowerAsciiLetter
(
chCode
))
{
if
(
ignoreUpperCase
&&
i
<
startIndex
&&
strings
.
isLowerAsciiLetter
(
chCode
))
{
return
i
;
return
i
;
}
}
if
(
chCode
===
CharCode
.
Underline
)
{
if
(
i
===
0
)
{
return
0
;
}
const
prevChCode
=
str
.
charCodeAt
(
i
-
1
);
if
(
prevChCode
!==
CharCode
.
Underline
)
{
return
i
-
1
;
}
}
ignoreUpperCase
=
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
);
ignoreUpperCase
=
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
);
}
}
return
-
1
;
return
-
1
;
...
@@ -490,7 +508,16 @@ export function _nextWordPartBegin(str: string, startIndex: number = 0): number
...
@@ -490,7 +508,16 @@ export function _nextWordPartBegin(str: string, startIndex: number = 0): number
let
ignoreUpperCase
=
strings
.
isUpperAsciiLetter
(
chCode
);
let
ignoreUpperCase
=
strings
.
isUpperAsciiLetter
(
chCode
);
for
(
let
i
=
startIndex
;
i
<
str
.
length
;
++
i
)
{
for
(
let
i
=
startIndex
;
i
<
str
.
length
;
++
i
)
{
chCode
=
str
.
charCodeAt
(
i
);
chCode
=
str
.
charCodeAt
(
i
);
if
(
chCode
===
CharCode
.
Space
||
chCode
===
CharCode
.
Tab
||
(
!
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
)))
{
if
(
chCode
===
CharCode
.
Space
||
chCode
===
CharCode
.
Tab
)
{
if
(
i
+
1
>=
str
.
length
)
{
return
i
+
1
;
}
const
nextChCode
=
str
.
charCodeAt
(
i
+
1
);
if
(
nextChCode
!==
CharCode
.
Space
&&
nextChCode
!==
CharCode
.
Tab
)
{
return
i
+
2
;
}
}
if
(
!
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
))
{
return
i
+
1
;
return
i
+
1
;
}
}
if
(
ignoreUpperCase
&&
strings
.
isLowerAsciiLetter
(
chCode
))
{
if
(
ignoreUpperCase
&&
strings
.
isLowerAsciiLetter
(
chCode
))
{
...
@@ -498,7 +525,13 @@ export function _nextWordPartBegin(str: string, startIndex: number = 0): number
...
@@ -498,7 +525,13 @@ export function _nextWordPartBegin(str: string, startIndex: number = 0): number
}
}
ignoreUpperCase
=
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
);
ignoreUpperCase
=
ignoreUpperCase
&&
strings
.
isUpperAsciiLetter
(
chCode
);
if
(
chCode
===
CharCode
.
Underline
)
{
if
(
chCode
===
CharCode
.
Underline
)
{
return
i
+
2
;
if
(
i
+
1
>=
str
.
length
)
{
return
i
+
1
;
}
const
nextChCode
=
str
.
charCodeAt
(
i
+
1
);
if
(
nextChCode
!==
CharCode
.
Underline
)
{
return
i
+
2
;
}
}
}
}
}
return
str
.
length
+
1
;
return
str
.
length
+
1
;
...
...
src/vs/editor/contrib/wordOperations/test/wordTestUtils.ts
浏览文件 @
04b42cf0
...
@@ -69,6 +69,10 @@ export function testRepeatedActionAndExtractPositions(text: string, initialPosit
...
@@ -69,6 +69,10 @@ export function testRepeatedActionAndExtractPositions(text: string, initialPosit
if
(
stopCondition
(
editor
))
{
if
(
stopCondition
(
editor
))
{
break
;
break
;
}
}
if
(
actualStops
.
length
>
1000
)
{
throw
new
Error
(
`Endless loop detected!`
);
}
}
}
});
});
return
actualStops
;
return
actualStops
;
...
...
src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts
浏览文件 @
04b42cf0
...
@@ -36,7 +36,7 @@ suite('WordPartOperations', () => {
...
@@ -36,7 +36,7 @@ suite('WordPartOperations', () => {
test
(
'
move word part left basic
'
,
()
=>
{
test
(
'
move word part left basic
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
|start| |line|
'
,
'
|start| |line|
'
,
'
|this|Is|A|Camel|Case|Var|
|
|this|_is|_a|_snake|_case|_var| |THIS|_IS|_CAPS|_SNAKE| |this|_IS|Mixed|Use|
'
,
'
|this|Is|A|Camel|Case|Var| |this|_is|_a|_snake|_case|_var| |THIS|_IS|_CAPS|_SNAKE| |this|_IS|Mixed|Use|
'
,
'
|end| |line
'
'
|end| |line
'
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
...
@@ -51,10 +51,38 @@ suite('WordPartOperations', () => {
...
@@ -51,10 +51,38 @@ suite('WordPartOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
issue #53899: move word part left whitespace
'
,
()
=>
{
const
EXPECTED
=
'
|myvar| |=| |
\'
|demonstration| |of| |selection| |with| |space
\'
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
new
Position
(
1000
,
1000
),
ed
=>
moveWordPartLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
test
(
'
issue #53899: move word part left underscores
'
,
()
=>
{
const
EXPECTED
=
'
|myvar| |=| |
\'
|demonstration|_____of| |selection| |with| |space
\'
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
new
Position
(
1000
,
1000
),
ed
=>
moveWordPartLeft
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
1
))
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
test
(
'
move word part right basic
'
,
()
=>
{
test
(
'
move word part right basic
'
,
()
=>
{
const
EXPECTED
=
[
const
EXPECTED
=
[
'
start| |line|
'
,
'
start| |line|
'
,
'
|this|Is|A|Camel|Case|Var|
|
|this_|is_|a_|snake_|case_|var| |THIS_|IS_|CAPS_|SNAKE| |this_|IS|Mixed|Use|
'
,
'
|this|Is|A|Camel|Case|Var| |this_|is_|a_|snake_|case_|var| |THIS_|IS_|CAPS_|SNAKE| |this_|IS|Mixed|Use|
'
,
'
|end| |line|
'
'
|end| |line|
'
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
...
@@ -69,6 +97,34 @@ suite('WordPartOperations', () => {
...
@@ -69,6 +97,34 @@ suite('WordPartOperations', () => {
assert
.
deepEqual
(
actual
,
EXPECTED
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
});
test
(
'
issue #53899: move word part right whitespace
'
,
()
=>
{
const
EXPECTED
=
'
myvar| =|
\'
demonstration| |of| |selection| |with| |space|
\'
|
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
new
Position
(
1
,
1
),
ed
=>
moveWordPartRight
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
52
))
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
test
(
'
issue #53899: move word part right underscores
'
,
()
=>
{
const
EXPECTED
=
'
myvar| =|
\'
demonstration_____|of| |selection| |with| |space|
\'
|
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
actualStops
=
testRepeatedActionAndExtractPositions
(
text
,
new
Position
(
1
,
1
),
ed
=>
moveWordPartRight
(
ed
),
ed
=>
ed
.
getPosition
(),
ed
=>
ed
.
getPosition
().
equals
(
new
Position
(
1
,
52
))
);
const
actual
=
serializePipePositions
(
text
,
actualStops
);
assert
.
deepEqual
(
actual
,
EXPECTED
);
});
test
(
'
delete word part left basic
'
,
()
=>
{
test
(
'
delete word part left basic
'
,
()
=>
{
const
EXPECTED
=
'
| |/*| |Just| |some| |text| |a|+=| |3| |+|5|-|3| |*/| |this|Is|A|Camel|Case|Var| |this|_is|_a|_snake|_case|_var| |THIS|_IS|_CAPS|_SNAKE| |this|_IS|Mixed|Use
'
;
const
EXPECTED
=
'
| |/*| |Just| |some| |text| |a|+=| |3| |+|5|-|3| |*/| |this|Is|A|Camel|Case|Var| |this|_is|_a|_snake|_case|_var| |THIS|_IS|_CAPS|_SNAKE| |this|_IS|Mixed|Use
'
;
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
const
[
text
,]
=
deserializePipePositions
(
EXPECTED
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录