Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eb1d9729
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eb1d9729
编写于
6月 04, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add option to allow for weak match as first match, use that option for outline (experiment) #50724
上级
424ac2e4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
3 deletion
+13
-3
src/vs/base/common/filters.ts
src/vs/base/common/filters.ts
+4
-2
src/vs/base/test/common/filters.test.ts
src/vs/base/test/common/filters.test.ts
+8
-0
src/vs/workbench/parts/outline/electron-browser/outlineModel.ts
.../workbench/parts/outline/electron-browser/outlineModel.ts
+1
-1
未找到文件。
src/vs/base/common/filters.ts
浏览文件 @
eb1d9729
...
...
@@ -454,7 +454,7 @@ const enum Arrow { Top = 0b1, Diag = 0b10, Left = 0b100 }
export
type
FuzzyScore
=
[
number
,
number
[]];
export
function
fuzzyScore
(
pattern
:
string
,
word
:
string
,
patternMaxWhitespaceIgnore
?:
number
):
FuzzyScore
{
export
function
fuzzyScore
(
pattern
:
string
,
word
:
string
,
patternMaxWhitespaceIgnore
?:
number
,
firstMatchCanBeWeak
?:
boolean
):
FuzzyScore
{
const
patternLen
=
pattern
.
length
>
100
?
100
:
pattern
.
length
;
const
wordLen
=
word
.
length
>
100
?
100
:
word
.
length
;
...
...
@@ -578,6 +578,7 @@ export function fuzzyScore(pattern: string, word: string, patternMaxWhitespaceIg
_matchesCount
=
0
;
_topScore
=
-
100
;
_patternStartPos
=
patternStartPos
;
_firstMatchCanBeWeak
=
firstMatchCanBeWeak
;
_findAllMatches
(
patternLen
,
wordLen
,
patternLen
===
wordLen
?
1
:
0
,
new
LazyArray
(),
false
);
if
(
_matchesCount
===
0
)
{
...
...
@@ -591,6 +592,7 @@ let _matchesCount: number = 0;
let
_topMatch
:
LazyArray
;
let
_topScore
:
number
=
0
;
let
_patternStartPos
:
number
=
0
;
let
_firstMatchCanBeWeak
:
boolean
=
false
;
function
_findAllMatches
(
patternPos
:
number
,
wordPos
:
number
,
total
:
number
,
matches
:
LazyArray
,
lastMatched
:
boolean
):
void
{
...
...
@@ -644,7 +646,7 @@ function _findAllMatches(patternPos: number, wordPos: number, total: number, mat
if
(
score
===
1
)
{
simpleMatchCount
+=
1
;
if
(
patternPos
===
_patternStartPos
)
{
if
(
patternPos
===
_patternStartPos
&&
!
_firstMatchCanBeWeak
)
{
// when the first match is a weak
// match we discard it
return
undefined
;
...
...
src/vs/base/test/common/filters.test.ts
浏览文件 @
eb1d9729
...
...
@@ -309,6 +309,14 @@ suite('Filters', () => {
assertMatches
(
'
fo
'
,
'
bar
\\
foo
'
,
'
bar
\\
^f^oo
'
,
fuzzyScore
);
});
test
(
'
fuzzyScore (first match can be weak)
'
,
function
()
{
let
fuzzyScoreWeak
=
(
pattern
,
word
)
=>
fuzzyScore
(
pattern
,
word
,
undefined
,
true
);
assertMatches
(
'
Three
'
,
'
HTMLHRElement
'
,
'
H^TML^H^R^El^ement
'
,
fuzzyScoreWeak
);
assertMatches
(
'
tor
'
,
'
constructor
'
,
'
construc^t^o^r
'
,
fuzzyScoreWeak
);
assertMatches
(
'
ur
'
,
'
constructor
'
,
'
constr^ucto^r
'
,
fuzzyScoreWeak
);
assertTopScore
(
fuzzyScoreWeak
,
'
tor
'
,
2
,
'
constructor
'
,
'
Thor
'
,
'
cTor
'
);
});
test
(
'
fuzzyScore, many matches
'
,
function
()
{
assertMatches
(
...
...
src/vs/workbench/parts/outline/electron-browser/outlineModel.ts
浏览文件 @
eb1d9729
...
...
@@ -105,7 +105,7 @@ export class OutlineGroup extends TreeElement {
}
private
_updateMatches
(
pattern
:
string
,
item
:
OutlineElement
,
topMatch
:
OutlineElement
):
OutlineElement
{
item
.
score
=
fuzzyScore
(
pattern
,
item
.
symbol
.
name
);
item
.
score
=
fuzzyScore
(
pattern
,
item
.
symbol
.
name
,
undefined
,
true
);
if
(
item
.
score
&&
(
!
topMatch
||
item
.
score
[
0
]
>
topMatch
.
score
[
0
]))
{
topMatch
=
item
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录