Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8e9151a4
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,体验更适合开发者的 AI 搜索 >>
提交
8e9151a4
编写于
1月 24, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ensure fuzzy score limit is what it is, #66923
上级
b3e5d256
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
25 deletion
+15
-25
src/vs/base/common/filters.ts
src/vs/base/common/filters.ts
+4
-15
src/vs/base/test/common/filters.test.ts
src/vs/base/test/common/filters.test.ts
+11
-10
未找到文件。
src/vs/base/common/filters.ts
浏览文件 @
8e9151a4
...
...
@@ -378,16 +378,13 @@ export function createMatches(score: undefined | FuzzyScore): IMatch[] {
return
[];
}
const
[,
matches
,
wordStart
]
=
score
;
const
matches
=
score
[
1
].
toString
(
2
);
const
wordStart
=
score
[
2
];
const
res
:
IMatch
[]
=
[];
for
(
let
pos
=
wordStart
;
pos
<
_masks
.
length
;
pos
++
)
{
const
mask
=
_masks
[
pos
];
if
(
mask
>
matches
)
{
break
;
}
else
if
(
matches
&
mask
)
{
for
(
let
pos
=
wordStart
;
pos
<
_maxLen
;
pos
++
)
{
if
(
matches
[
matches
.
length
-
(
pos
+
1
)]
===
'
1
'
)
{
const
last
=
res
[
res
.
length
-
1
];
if
(
last
&&
last
.
end
===
pos
)
{
last
.
end
=
pos
+
1
;
}
else
{
...
...
@@ -400,14 +397,6 @@ export function createMatches(score: undefined | FuzzyScore): IMatch[] {
const
_maxLen
=
53
;
const
_masks
=
(
function
()
{
const
result
:
number
[]
=
[];
for
(
let
pos
=
0
;
pos
<
_maxLen
;
pos
++
)
{
result
.
push
(
2
**
pos
);
}
return
result
;
}());
function
initTable
()
{
const
table
:
number
[][]
=
[];
const
row
:
number
[]
=
[
0
];
...
...
src/vs/base/test/common/filters.test.ts
浏览文件 @
8e9151a4
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
IFilter
,
or
,
matchesPrefix
,
matchesStrictPrefix
,
matchesCamelCase
,
matchesSubString
,
matchesContiguousSubString
,
matchesWords
,
fuzzyScore
,
IMatch
,
fuzzyScoreGraceful
,
fuzzyScoreGracefulAggressive
,
FuzzyScorer
}
from
'
vs/base/common/filters
'
;
import
{
IFilter
,
or
,
matchesPrefix
,
matchesStrictPrefix
,
matchesCamelCase
,
matchesSubString
,
matchesContiguousSubString
,
matchesWords
,
fuzzyScore
,
IMatch
,
fuzzyScoreGraceful
,
fuzzyScoreGracefulAggressive
,
FuzzyScorer
,
createMatches
}
from
'
vs/base/common/filters
'
;
function
filterOk
(
filter
:
IFilter
,
word
:
string
,
wordToMatchAgainst
:
string
,
highlights
?:
{
start
:
number
;
end
:
number
;
}[])
{
let
r
=
filter
(
word
,
wordToMatchAgainst
);
...
...
@@ -208,14 +208,15 @@ suite('Filters', () => {
let
r
=
filter
(
pattern
,
pattern
.
toLowerCase
(),
opts
.
patternPos
||
0
,
word
,
word
.
toLowerCase
(),
opts
.
wordPos
||
0
,
opts
.
firstMatchCanBeWeak
||
false
);
assert
.
ok
(
!
decoratedWord
===
!
r
);
if
(
r
)
{
let
[,
matches
]
=
r
;
let
matches
=
createMatches
(
r
)
;
let
actualWord
=
''
;
for
(
let
pos
=
0
;
pos
<
word
.
length
;
pos
++
)
{
if
(
2
**
pos
&
matches
)
{
actualWord
+=
'
^
'
;
}
actualWord
+=
word
[
pos
]
;
let
pos
=
0
;
for
(
const
match
of
matches
)
{
actualWord
+=
word
.
substring
(
pos
,
match
.
start
)
;
actualWord
+=
'
^
'
+
word
.
substring
(
match
.
start
,
match
.
end
).
split
(
''
).
join
(
'
^
'
);
pos
=
match
.
end
;
}
actualWord
+=
word
.
substring
(
pos
);
assert
.
equal
(
actualWord
,
decoratedWord
);
}
}
...
...
@@ -450,7 +451,7 @@ suite('Filters', () => {
assertMatches
(
'
cno
'
,
'
co_new
'
,
'
^c^o_^new
'
,
fuzzyScoreGracefulAggressive
);
});
//
test('List highlight filter: Not all characters from match are highlighterd #66923', () => {
//
assertMatches('foo', 'barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_foo', 'barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_^f^o^o', fuzzyScore);
//
});
test
(
'
List highlight filter: Not all characters from match are highlighterd #66923
'
,
()
=>
{
assertMatches
(
'
foo
'
,
'
barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_foo
'
,
'
barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_^f^o^o
'
,
fuzzyScore
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录