Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7272e29f
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7272e29f
编写于
3月 17, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quick access - restore matching as it was before for editor history entries
上级
461c563f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
5 deletion
+23
-5
src/vs/base/parts/quickinput/common/quickInput.ts
src/vs/base/parts/quickinput/common/quickInput.ts
+15
-2
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
...s/workbench/contrib/search/browser/anythingQuickAccess.ts
+8
-3
未找到文件。
src/vs/base/parts/quickinput/common/quickInput.ts
浏览文件 @
7272e29f
...
...
@@ -308,22 +308,35 @@ export type QuickPickInput<T = IQuickPickItem> = T | IQuickPickSeparator;
export
type
IQuickPickItemWithResource
=
IQuickPickItem
&
{
resource
:
URI
|
undefined
};
export
const
quickPickItemScorerAccessor
=
new
class
implements
IItemAccessor
<
IQuickPickItemWithResource
>
{
export
class
QuickPickItemScorerAccessor
implements
IItemAccessor
<
IQuickPickItemWithResource
>
{
constructor
(
private
options
?:
{
skipDescription
?:
boolean
,
skipPath
?:
boolean
})
{
}
getItemLabel
(
entry
:
IQuickPickItemWithResource
):
string
{
return
entry
.
label
;
}
getItemDescription
(
entry
:
IQuickPickItemWithResource
):
string
|
undefined
{
if
(
this
.
options
?.
skipDescription
)
{
return
undefined
;
}
return
entry
.
description
;
}
getItemPath
(
entry
:
IQuickPickItemWithResource
):
string
|
undefined
{
if
(
this
.
options
?.
skipPath
)
{
return
undefined
;
}
if
(
entry
.
resource
?.
scheme
===
Schemas
.
file
)
{
return
entry
.
resource
.
fsPath
;
}
return
entry
.
resource
?.
path
;
}
};
}
export
const
quickPickItemScorerAccessor
=
new
QuickPickItemScorerAccessor
();
//#endregion
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
浏览文件 @
7272e29f
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
'
vs/css!./media/anythingQuickAccess
'
;
import
{
IQuickPickSeparator
,
IQuickInputButton
,
IKeyMods
,
quickPickItemScorerAccessor
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IQuickPickSeparator
,
IQuickInputButton
,
IKeyMods
,
quickPickItemScorerAccessor
,
QuickPickItemScorerAccessor
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IPickerQuickAccessItem
,
PickerQuickAccessProvider
,
TriggerAction
,
FastAndSlowPicksType
}
from
'
vs/platform/quickinput/browser/pickerQuickAccess
'
;
import
{
prepareQuery
,
IPreparedQuery
,
compareItemsByScore
,
scoreItem
}
from
'
vs/base/common/fuzzyScorer
'
;
import
{
IFileQueryBuilderOptions
,
QueryBuilder
}
from
'
vs/workbench/contrib/search/common/queryBuilder
'
;
...
...
@@ -168,6 +168,8 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
//#region Editor History
private
readonly
labelOnlyEditorHistoryPickAccessor
=
new
QuickPickItemScorerAccessor
({
skipDescription
:
true
});
protected
getEditorHistoryPicks
(
query
:
IPreparedQuery
,
range
:
IRange
|
undefined
):
Array
<
IAnythingQuickPickItem
>
{
if
(
!
this
.
configuration
.
includeHistory
)
{
return
[];
// disabled
...
...
@@ -178,6 +180,9 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
return
this
.
historyService
.
getHistory
().
map
(
editor
=>
this
.
createAnythingPick
(
editor
,
range
));
}
// Only match on label of the editor unless the search includes path separators
const
editorHistoryScorerAccessor
=
query
.
containsPathSeparator
?
quickPickItemScorerAccessor
:
this
.
labelOnlyEditorHistoryPickAccessor
;
// Otherwise filter and sort by query
const
editorHistoryPicks
:
Array
<
IAnythingQuickPickItem
>
=
[];
const
scorerCache
=
Object
.
create
(
null
);
// TODO should keep this for as long as the picker is opened (also check other pickers)
...
...
@@ -189,7 +194,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
const
editorHistoryPick
=
this
.
createAnythingPick
(
editor
,
range
);
const
{
score
,
labelMatch
,
descriptionMatch
}
=
scoreItem
(
editorHistoryPick
,
query
,
false
,
quickPickItem
ScorerAccessor
,
scorerCache
);
const
{
score
,
labelMatch
,
descriptionMatch
}
=
scoreItem
(
editorHistoryPick
,
query
,
false
,
editorHistory
ScorerAccessor
,
scorerCache
);
if
(
!
score
)
{
continue
;
// exclude editors not matching query
}
...
...
@@ -202,7 +207,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
editorHistoryPicks
.
push
(
editorHistoryPick
);
}
return
editorHistoryPicks
.
sort
((
editorA
,
editorB
)
=>
compareItemsByScore
(
editorA
,
editorB
,
query
,
false
,
quickPickItem
ScorerAccessor
,
scorerCache
,
()
=>
-
1
));
return
editorHistoryPicks
.
sort
((
editorA
,
editorB
)
=>
compareItemsByScore
(
editorA
,
editorB
,
query
,
false
,
editorHistory
ScorerAccessor
,
scorerCache
,
()
=>
-
1
));
}
//#endregion
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录