Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
86fa120c
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,发现更多精彩内容 >>
提交
86fa120c
编写于
9月 21, 2019
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #81129
上级
a817a588
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
12 addition
and
13 deletion
+12
-13
src/vs/workbench/contrib/search/common/searchModel.ts
src/vs/workbench/contrib/search/common/searchModel.ts
+7
-8
src/vs/workbench/contrib/search/test/common/searchResult.test.ts
...workbench/contrib/search/test/common/searchResult.test.ts
+5
-5
未找到文件。
src/vs/workbench/contrib/search/common/searchModel.ts
浏览文件 @
86fa120c
...
...
@@ -107,12 +107,12 @@ export class Match {
// If match string is not matching then regex pattern has a lookahead expression
if
(
replaceString
===
null
)
{
const
fullMatchTextWith
Trail
ingContent
=
this
.
fullMatchText
(
true
);
replaceString
=
searchModel
.
replacePattern
.
getReplaceString
(
fullMatchTextWith
Trail
ingContent
,
searchModel
.
preserveCase
);
const
fullMatchTextWith
Surround
ingContent
=
this
.
fullMatchText
(
true
);
replaceString
=
searchModel
.
replacePattern
.
getReplaceString
(
fullMatchTextWith
Surround
ingContent
,
searchModel
.
preserveCase
);
// Search/find normalize line endings - check whether \r prevents regex from matching
if
(
replaceString
===
null
)
{
const
fullMatchTextWithoutCR
=
fullMatchTextWith
Trail
ingContent
.
replace
(
/
\r\n
/g
,
'
\n
'
);
const
fullMatchTextWithoutCR
=
fullMatchTextWith
Surround
ingContent
.
replace
(
/
\r\n
/g
,
'
\n
'
);
replaceString
=
searchModel
.
replacePattern
.
getReplaceString
(
fullMatchTextWithoutCR
,
searchModel
.
preserveCase
);
}
}
...
...
@@ -125,17 +125,16 @@ export class Match {
return
replaceString
;
}
fullMatchText
(
include
Trail
ing
=
false
):
string
{
fullMatchText
(
include
Surround
ing
=
false
):
string
{
let
thisMatchPreviewLines
:
string
[];
if
(
include
Trail
ing
)
{
thisMatchPreviewLines
=
this
.
_fullPreviewLines
.
slice
(
this
.
_fullPreviewRange
.
startLineNumber
)
;
if
(
include
Surround
ing
)
{
thisMatchPreviewLines
=
this
.
_fullPreviewLines
;
}
else
{
thisMatchPreviewLines
=
this
.
_fullPreviewLines
.
slice
(
this
.
_fullPreviewRange
.
startLineNumber
,
this
.
_fullPreviewRange
.
endLineNumber
+
1
);
thisMatchPreviewLines
[
thisMatchPreviewLines
.
length
-
1
]
=
thisMatchPreviewLines
[
thisMatchPreviewLines
.
length
-
1
].
slice
(
0
,
this
.
_fullPreviewRange
.
endColumn
);
thisMatchPreviewLines
[
0
]
=
thisMatchPreviewLines
[
0
].
slice
(
this
.
_fullPreviewRange
.
startColumn
);
}
thisMatchPreviewLines
[
0
]
=
thisMatchPreviewLines
[
0
].
slice
(
this
.
_fullPreviewRange
.
startColumn
);
return
thisMatchPreviewLines
.
join
(
'
\n
'
);
}
...
...
src/vs/workbench/contrib/search/test/common/searchResult.test.ts
浏览文件 @
86fa120c
...
...
@@ -33,16 +33,16 @@ suite('SearchResult', () => {
test
(
'
Line Match
'
,
function
()
{
const
fileMatch
=
aFileMatch
(
'
folder/file.txt
'
,
null
!
);
const
lineMatch
=
new
Match
(
fileMatch
,
[
'
foo bar
'
],
new
OneLineRange
(
0
,
0
,
3
),
new
OneLineRange
(
1
,
0
,
3
));
assert
.
equal
(
lineMatch
.
text
(),
'
foo bar
'
);
const
lineMatch
=
new
Match
(
fileMatch
,
[
'
0 foo bar
'
],
new
OneLineRange
(
0
,
2
,
5
),
new
OneLineRange
(
1
,
0
,
5
));
assert
.
equal
(
lineMatch
.
text
(),
'
0
foo bar
'
);
assert
.
equal
(
lineMatch
.
range
().
startLineNumber
,
2
);
assert
.
equal
(
lineMatch
.
range
().
endLineNumber
,
2
);
assert
.
equal
(
lineMatch
.
range
().
startColumn
,
1
);
assert
.
equal
(
lineMatch
.
range
().
endColumn
,
4
);
assert
.
equal
(
'
file:///folder/file.txt>[2,1 -> 2,4]foo
'
,
lineMatch
.
id
()
);
assert
.
equal
(
lineMatch
.
range
().
endColumn
,
6
);
assert
.
equal
(
lineMatch
.
id
(),
'
file:///folder/file.txt>[2,1 -> 2,6]foo
'
);
assert
.
equal
(
lineMatch
.
fullMatchText
(),
'
foo
'
);
assert
.
equal
(
lineMatch
.
fullMatchText
(
true
),
'
foo bar
'
);
assert
.
equal
(
lineMatch
.
fullMatchText
(
true
),
'
0
foo bar
'
);
});
test
(
'
Line Match - Remove
'
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录