Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
27a2bfef
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,发现更多精彩内容 >>
提交
27a2bfef
编写于
10月 23, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tests (for #35572)
上级
6779069b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
15 deletion
+51
-15
src/vs/base/common/filters.ts
src/vs/base/common/filters.ts
+1
-1
src/vs/base/parts/quickopen/common/quickOpenScorer.ts
src/vs/base/parts/quickopen/common/quickOpenScorer.ts
+37
-14
src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts
.../base/parts/quickopen/test/common/quickOpenScorer.test.ts
+13
-0
未找到文件。
src/vs/base/common/filters.ts
浏览文件 @
27a2bfef
...
...
@@ -421,7 +421,7 @@ function printTable(table: number[][], pattern: string, patternLen: number, word
return
ret
;
}
export
function
isSeparatorAtPos
(
value
:
string
,
index
:
number
):
boolean
{
function
isSeparatorAtPos
(
value
:
string
,
index
:
number
):
boolean
{
if
(
index
<
0
||
index
>=
value
.
length
)
{
return
false
;
}
...
...
src/vs/base/parts/quickopen/common/quickOpenScorer.ts
浏览文件 @
27a2bfef
...
...
@@ -6,10 +6,11 @@
'
use strict
'
;
import
{
compareAnything
}
from
'
vs/base/common/comparers
'
;
import
{
matchesPrefix
,
IMatch
,
createMatches
,
matchesCamelCase
,
is
SeparatorAtPos
,
is
Upper
}
from
'
vs/base/common/filters
'
;
import
{
matchesPrefix
,
IMatch
,
createMatches
,
matchesCamelCase
,
isUpper
}
from
'
vs/base/common/filters
'
;
import
{
isEqual
,
nativeSep
}
from
'
vs/base/common/paths
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
stripWildcards
}
from
'
vs/base/common/strings
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
export
type
Score
=
[
number
/* score */
,
number
[]
/* match positions */
];
export
type
ScorerCache
=
{
[
key
:
string
]:
IItemScore
};
...
...
@@ -189,22 +190,26 @@ function computeCharScore(query: string, queryLower: string, queryIndex: number,
// }
}
// After separator bonus
else
if
(
isSeparatorAtPos
(
target
,
targetIndex
-
1
))
{
score
+=
4
;
else
{
//
if (DEBUG) {
// console.log('After separtor bonus: +4'
);
// }
}
//
After separator bonus
const
separatorBonus
=
scoreSeparatorAtPos
(
target
.
charCodeAt
(
targetIndex
-
1
)
);
if
(
separatorBonus
)
{
score
+=
separatorBonus
;
// Inside word upper case bonus
else
if
(
isUpper
(
target
.
charCodeAt
(
targetIndex
)))
{
score
+=
1
;
// if (DEBUG) {
// console.log('After separtor bonus: +4');
// }
}
// if (DEBUG) {
// console.log('Inside word upper case bonus: +1');
// }
// Inside word upper case bonus (camel case)
else
if
(
isUpper
(
target
.
charCodeAt
(
targetIndex
)))
{
score
+=
1
;
// if (DEBUG) {
// console.log('Inside word upper case bonus: +1');
// }
}
}
// if (DEBUG) {
...
...
@@ -214,6 +219,24 @@ function computeCharScore(query: string, queryLower: string, queryIndex: number,
return
score
;
}
function
scoreSeparatorAtPos
(
charCode
:
number
):
number
{
switch
(
charCode
)
{
case
CharCode
.
Slash
:
case
CharCode
.
Backslash
:
return
5
;
// prefer path separators...
case
CharCode
.
Underline
:
case
CharCode
.
Dash
:
case
CharCode
.
Period
:
case
CharCode
.
Space
:
case
CharCode
.
SingleQuote
:
case
CharCode
.
DoubleQuote
:
case
CharCode
.
Colon
:
return
4
;
// ...over other separators
default
:
return
0
;
}
}
// function printMatrix(query: string, target: string, matches: number[], scores: number[]): void {
// console.log('\t' + target.split('').join('\t'));
// for (let queryIndex = 0; queryIndex < query.length; queryIndex++) {
...
...
src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts
浏览文件 @
27a2bfef
...
...
@@ -715,6 +715,19 @@ suite('Quick Open Scorer', () => {
assert
.
equal
(
res
[
0
],
resourceB
);
});
test
(
'
compareFilesByScore - avoid match scattering (bug #35572)
'
,
function
()
{
const
resourceA
=
URI
.
file
(
'
static/app/source/angluar/-admin/-organization/-settings/layout/layout.js
'
);
const
resourceB
=
URI
.
file
(
'
static/app/source/angular/-admin/-project/-settings/_settings/settings.js
'
);
let
query
=
'
partisettings
'
;
let
res
=
[
resourceA
,
resourceB
].
sort
((
r1
,
r2
)
=>
compareItemsByScore
(
r1
,
r2
,
query
,
true
,
ResourceAccessor
,
cache
));
assert
.
equal
(
res
[
0
],
resourceB
);
res
=
[
resourceB
,
resourceA
].
sort
((
r1
,
r2
)
=>
compareItemsByScore
(
r1
,
r2
,
query
,
true
,
ResourceAccessor
,
cache
));
assert
.
equal
(
res
[
0
],
resourceB
);
});
test
(
'
compareFilesByScore - prefer shorter hit (bug #20546)
'
,
function
()
{
const
resourceA
=
URI
.
file
(
'
editor/core/components/tests/list-view-spec.js
'
);
const
resourceB
=
URI
.
file
(
'
editor/core/components/list-view.js
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录