Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4d85f2ed
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,发现更多精彩内容 >>
提交
4d85f2ed
编写于
7月 13, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #6053: handle reaching end of line while searching better
上级
ed9e56b2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
10 deletion
+65
-10
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+9
-1
src/vs/editor/contrib/find/test/common/findModel.test.ts
src/vs/editor/contrib/find/test/common/findModel.test.ts
+29
-0
src/vs/editor/test/common/model/model.test.ts
src/vs/editor/test/common/model/model.test.ts
+27
-9
未找到文件。
src/vs/editor/common/model/textModel.ts
浏览文件 @
4d85f2ed
...
...
@@ -999,6 +999,10 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
break
;
}
bestResult
=
result
;
if
(
m
.
index
+
m
[
0
].
length
===
text
.
length
)
{
// Reached the end of the line
break
;
}
}
return
bestResult
;
}
...
...
@@ -1011,8 +1015,8 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
m
=
searchRegex
.
exec
(
text
);
if
(
m
)
{
var
range
=
new
Range
(
lineNumber
,
m
.
index
+
1
+
deltaOffset
,
lineNumber
,
m
.
index
+
1
+
m
[
0
].
length
+
deltaOffset
);
// Exit early if the regex matches the same range
if
(
range
.
equalsRange
(
result
[
result
.
length
-
1
]))
{
// Exit early if the regex matches the same range
return
counter
;
}
result
.
push
(
range
);
...
...
@@ -1020,6 +1024,10 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
if
(
counter
>=
limitResultCount
)
{
return
counter
;
}
if
(
m
.
index
+
m
[
0
].
length
===
text
.
length
)
{
// Reached the end of the line
return
counter
;
}
}
}
while
(
m
);
return
counter
;
...
...
src/vs/editor/contrib/find/test/common/findModel.test.ts
浏览文件 @
4d85f2ed
...
...
@@ -963,6 +963,35 @@ suite('FindModel', () => {
findState
.
dispose
();
});
findTest
(
'
find .*
'
,
(
editor
,
cursor
)
=>
{
let
findState
=
new
FindReplaceState
();
findState
.
change
({
searchString
:
'
.*
'
,
isRegex
:
true
},
false
);
let
findModel
=
new
FindModelBoundToEditorModel
(
editor
,
findState
);
assertFindState
(
editor
,
[
1
,
1
,
1
,
1
],
null
,
[
[
1
,
1
,
1
,
18
],
[
2
,
1
,
2
,
18
],
[
3
,
1
,
3
,
20
],
[
4
,
1
,
4
,
1
],
[
5
,
1
,
5
,
13
],
[
6
,
1
,
6
,
43
],
[
7
,
1
,
7
,
41
],
[
8
,
1
,
8
,
41
],
[
9
,
1
,
9
,
40
],
[
10
,
1
,
10
,
2
],
[
11
,
1
,
11
,
17
],
[
12
,
1
,
12
,
1
],
]
);
findModel
.
dispose
();
findState
.
dispose
();
});
findTest
(
'
find next ^.*$
'
,
(
editor
,
cursor
)
=>
{
let
findState
=
new
FindReplaceState
();
findState
.
change
({
searchString
:
'
^.*$
'
,
isRegex
:
true
},
false
);
...
...
src/vs/editor/test/common/model/model.test.ts
浏览文件 @
4d85f2ed
...
...
@@ -528,22 +528,26 @@ suite('Editor Model - Find', () => {
let
actualRanges
=
model
.
findMatches
(
searchString
,
false
,
isRegex
,
matchCase
,
wholeWord
);
let
actual
=
actualRanges
.
map
(
toArrRange
);
assert
.
deepEqual
(
actual
,
expected
);
assert
.
deepEqual
(
actual
,
expected
,
'
findMatches OK
'
);
// test `findNextMatch`
let
match
=
model
.
findNextMatch
(
searchString
,
new
Position
(
1
,
1
),
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
0
]);
let
startPos
=
new
Position
(
1
,
1
);
let
match
=
model
.
findNextMatch
(
searchString
,
startPos
,
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
0
],
`findNextMatch
${
startPos
}
`
);
for
(
let
i
=
0
;
i
<
expected
.
length
;
i
++
)
{
match
=
model
.
findNextMatch
(
searchString
,
new
Position
(
expected
[
i
][
0
],
expected
[
i
][
1
]),
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
i
]);
startPos
=
new
Position
(
expected
[
i
][
0
],
expected
[
i
][
1
]);
match
=
model
.
findNextMatch
(
searchString
,
startPos
,
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
i
],
`findNextMatch
${
startPos
}
`
);
}
// test `findPrevMatch`
match
=
model
.
findPreviousMatch
(
searchString
,
new
Position
(
model
.
getLineCount
(),
model
.
getLineMaxColumn
(
model
.
getLineCount
())),
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
expected
.
length
-
1
]);
startPos
=
new
Position
(
model
.
getLineCount
(),
model
.
getLineMaxColumn
(
model
.
getLineCount
()));
match
=
model
.
findPreviousMatch
(
searchString
,
startPos
,
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
expected
.
length
-
1
],
`findPrevMatch
${
startPos
}
`
);
for
(
let
i
=
0
;
i
<
expected
.
length
;
i
++
)
{
match
=
model
.
findPreviousMatch
(
searchString
,
new
Position
(
expected
[
i
][
2
],
expected
[
i
][
3
]),
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
i
]);
startPos
=
new
Position
(
expected
[
i
][
2
],
expected
[
i
][
3
]);
match
=
model
.
findPreviousMatch
(
searchString
,
startPos
,
isRegex
,
matchCase
,
wholeWord
);
assert
.
deepEqual
(
toArrRange
(
match
),
expected
[
i
],
`findPrevMatch
${
startPos
}
`
);
}
model
.
dispose
();
...
...
@@ -623,6 +627,20 @@ suite('Editor Model - Find', () => {
);
});
test
(
'
/.*/ find
'
,
()
=>
{
assertFindMatches
(
regularText
.
join
(
'
\n
'
),
'
.*
'
,
true
,
false
,
false
,
[
[
1
,
1
,
1
,
74
],
[
2
,
1
,
2
,
69
],
[
3
,
1
,
3
,
54
],
[
4
,
1
,
4
,
65
],
[
5
,
1
,
5
,
31
]
]
);
});
test
(
'
/^$/ find
'
,
()
=>
{
assertFindMatches
(
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录