Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
104c2fac
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,发现更多精彩内容 >>
提交
104c2fac
编写于
3月 17, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quick access - keep highlights from symbols untouched
上级
7272e29f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
29 deletion
+27
-29
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
...s/workbench/contrib/search/browser/anythingQuickAccess.ts
+8
-4
src/vs/workbench/contrib/search/browser/symbolsQuickAccess.ts
...vs/workbench/contrib/search/browser/symbolsQuickAccess.ts
+19
-25
未找到文件。
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
浏览文件 @
104c2fac
...
...
@@ -38,7 +38,7 @@ import { IResourceEditorInput, ITextEditorOptions } from 'vs/platform/editor/com
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IFilesConfigurationService
,
AutoSaveMode
}
from
'
vs/workbench/services/filesConfiguration/common/filesConfigurationService
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
SymbolsQuickAccessProvider
,
ISymbolsQuickPickItem
}
from
'
vs/workbench/contrib/search/browser/symbolsQuickAccess
'
;
import
{
SymbolsQuickAccessProvider
}
from
'
vs/workbench/contrib/search/browser/symbolsQuickAccess
'
;
interface
IAnythingQuickPickItem
extends
IPickerQuickAccessItem
{
resource
:
URI
|
undefined
;
...
...
@@ -154,6 +154,10 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
// Adjust highlights
for
(
const
anythingPick
of
sortedAnythingPicks
)
{
if
(
anythingPick
.
highlights
)
{
continue
;
// preserve any highlights we got already (e.g. symbols)
}
const
{
labelMatch
,
descriptionMatch
}
=
scoreItem
(
anythingPick
,
query
,
true
,
quickPickItemScorerAccessor
,
scorerCache
);
anythingPick
.
highlights
=
{
...
...
@@ -337,7 +341,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
private
symbolsQuickAccess
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SymbolsQuickAccessProvider
));
protected
async
getSymbolPicks
(
query
:
IPreparedQuery
,
range
:
IRange
|
undefined
,
token
:
CancellationToken
):
Promise
<
Array
<
I
Symbols
QuickPickItem
>>
{
protected
async
getSymbolPicks
(
query
:
IPreparedQuery
,
range
:
IRange
|
undefined
,
token
:
CancellationToken
):
Promise
<
Array
<
I
Anything
QuickPickItem
>>
{
if
(
!
query
.
value
||
// we need a value for search for
!
this
.
configuration
.
includeSymbols
||
// we need to enable symbols in search
...
...
@@ -347,7 +351,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
}
// Delegate to the existing symbols quick access
return
this
.
symbolsQuickAccess
.
getSymbolPicks
(
query
.
value
,
token
,
{
skipLocal
:
true
,
skipSorting
:
true
,
skipMatching
:
true
});
return
this
.
symbolsQuickAccess
.
getSymbolPicks
(
query
.
value
,
token
,
{
skipLocal
:
true
,
skipSorting
:
true
});
}
//#endregion
...
...
@@ -382,7 +386,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
localize
(
'
historyPickAriaLabel
'
,
"
{0}, recently opened
"
,
label
)
:
localize
(
'
filePickAriaLabel
'
,
"
{0}, file picker
"
,
label
),
description
,
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
resource
),
// TODO force 'file' icon if symbols are merged in for better looks
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
resource
),
buttonsAlwaysVisible
:
isDirty
,
buttons
:
(()
=>
{
const
openSideBySideDirection
=
this
.
configuration
.
openSideBySideDirection
;
...
...
src/vs/workbench/contrib/search/browser/symbolsQuickAccess.ts
浏览文件 @
104c2fac
...
...
@@ -25,19 +25,19 @@ import { createResourceExcludeMatcher } from 'vs/workbench/services/search/commo
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
interface
ISymbols
QuickPickItem
extends
IPickerQuickAccessItem
{
interface
ISymbol
QuickPickItem
extends
IPickerQuickAccessItem
{
resource
:
URI
|
undefined
;
score
:
FuzzyScore
|
undefined
;
symbol
:
IWorkspaceSymbol
;
}
export
class
SymbolsQuickAccessProvider
extends
PickerQuickAccessProvider
<
ISymbol
s
QuickPickItem
>
{
export
class
SymbolsQuickAccessProvider
extends
PickerQuickAccessProvider
<
ISymbolQuickPickItem
>
{
static
PREFIX
=
'
#
'
;
private
static
readonly
TYPING_SEARCH_DELAY
=
200
;
// this delay accommodates for the user typing a word and then stops typing to start searching
private
delayer
=
this
.
_register
(
new
ThrottledDelayer
<
ISymbol
s
QuickPickItem
[]
>
(
SymbolsQuickAccessProvider
.
TYPING_SEARCH_DELAY
));
private
delayer
=
this
.
_register
(
new
ThrottledDelayer
<
ISymbolQuickPickItem
[]
>
(
SymbolsQuickAccessProvider
.
TYPING_SEARCH_DELAY
));
private
readonly
resourceExcludeMatcher
=
this
.
_register
(
createResourceExcludeMatcher
(
this
.
instantiationService
,
this
.
configurationService
));
...
...
@@ -60,7 +60,7 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
};
}
protected
getPicks
(
filter
:
string
,
disposables
:
DisposableStore
,
token
:
CancellationToken
):
Promise
<
Array
<
ISymbol
s
QuickPickItem
>>
{
protected
getPicks
(
filter
:
string
,
disposables
:
DisposableStore
,
token
:
CancellationToken
):
Promise
<
Array
<
ISymbolQuickPickItem
>>
{
return
this
.
delayer
.
trigger
(
async
()
=>
{
if
(
token
.
isCancellationRequested
)
{
return
[];
...
...
@@ -70,13 +70,13 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
});
}
async
getSymbolPicks
(
filter
:
string
,
token
:
CancellationToken
,
options
?:
{
skipLocal
:
boolean
,
skipSorting
:
boolean
,
skipMatching
:
boolean
}):
Promise
<
Array
<
ISymbols
QuickPickItem
>>
{
async
getSymbolPicks
(
filter
:
string
,
token
:
CancellationToken
,
options
?:
{
skipLocal
:
boolean
,
skipSorting
:
boolean
}):
Promise
<
Array
<
ISymbol
QuickPickItem
>>
{
const
workspaceSymbols
=
await
getWorkspaceSymbols
(
filter
,
token
);
if
(
token
.
isCancellationRequested
)
{
return
[];
}
const
symbolPicks
:
Array
<
ISymbol
s
QuickPickItem
>
=
[];
const
symbolPicks
:
Array
<
ISymbolQuickPickItem
>
=
[];
// Normalize filter
const
[
symbolFilter
,
containerFilter
]
=
stripWildcards
(
filter
).
split
(
'
'
)
as
[
string
,
string
|
undefined
];
...
...
@@ -92,9 +92,14 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
continue
;
// ignore local symbols if we are told so
}
const
symbolUri
=
symbol
.
location
.
uri
;
// Score by symbol label
const
symbolLabel
=
symbol
.
name
;
const
symbolScore
=
fuzzyScore
(
symbolFilter
,
symbolFilterLow
,
0
,
symbolLabel
,
symbolLabel
.
toLowerCase
(),
0
,
true
);
if
(
!
symbolScore
)
{
continue
;
}
const
symbolUri
=
symbol
.
location
.
uri
;
let
containerLabel
:
string
|
undefined
=
undefined
;
if
(
symbolUri
)
{
const
containerPath
=
this
.
labelService
.
getUriLabel
(
symbolUri
,
{
relative
:
true
});
...
...
@@ -105,26 +110,15 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
}
}
// Score (only if enabled)
let
symbolScore
:
FuzzyScore
|
undefined
=
undefined
;
// Score by container if specified
let
containerScore
:
FuzzyScore
|
undefined
=
undefined
;
if
(
!
options
?.
skipMatching
)
{
// Score by symbol label
symbolScore
=
fuzzyScore
(
symbolFilter
,
symbolFilterLow
,
0
,
symbolLabel
,
symbolLabel
.
toLowerCase
(),
0
,
true
);
if
(
!
symbolScore
)
{
continue
;
if
(
containerFilter
&&
containerFilterLow
)
{
if
(
containerLabel
)
{
containerScore
=
fuzzyScore
(
containerFilter
,
containerFilterLow
,
0
,
containerLabel
,
containerLabel
.
toLowerCase
(),
0
,
true
);
}
// Score by container if specified
if
(
containerFilter
&&
containerFilterLow
)
{
if
(
containerLabel
)
{
containerScore
=
fuzzyScore
(
containerFilter
,
containerFilterLow
,
0
,
containerLabel
,
containerLabel
.
toLowerCase
(),
0
,
true
);
}
if
(
!
containerScore
)
{
continue
;
}
if
(
!
containerScore
)
{
continue
;
}
}
...
...
@@ -210,7 +204,7 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
}
}
private
compareSymbols
(
symbolA
:
ISymbol
sQuickPickItem
,
symbolB
:
ISymbols
QuickPickItem
):
number
{
private
compareSymbols
(
symbolA
:
ISymbol
QuickPickItem
,
symbolB
:
ISymbol
QuickPickItem
):
number
{
// By score
if
(
symbolA
.
score
&&
symbolB
.
score
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录