Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
461c563f
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,发现更多精彩内容 >>
提交
461c563f
编写于
3月 17, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quick access - first cut of symbols in anything access
上级
ae391417
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
21 deletion
+39
-21
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
...s/workbench/contrib/search/browser/anythingQuickAccess.ts
+7
-3
src/vs/workbench/contrib/search/browser/symbolsQuickAccess.ts
...vs/workbench/contrib/search/browser/symbolsQuickAccess.ts
+32
-18
未找到文件。
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
浏览文件 @
461c563f
...
...
@@ -38,6 +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
'
;
interface
IAnythingQuickPickItem
extends
IPickerQuickAccessItem
{
resource
:
URI
|
undefined
;
...
...
@@ -136,7 +137,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
// Resolve file and symbol picks (if enabled)
const
[
filePicks
,
symbolPicks
]
=
await
Promise
.
all
([
this
.
getFilePicks
(
query
,
range
,
excludes
,
token
),
this
.
getSymbolPicks
(
query
,
range
,
excludes
,
token
)
this
.
getSymbolPicks
(
query
,
range
,
token
)
]);
if
(
token
.
isCancellationRequested
)
{
...
...
@@ -329,7 +330,9 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
//#region Symbols (if enabled)
protected
async
getSymbolPicks
(
query
:
IPreparedQuery
,
range
:
IRange
|
undefined
,
excludes
:
ResourceMap
<
boolean
>
,
token
:
CancellationToken
):
Promise
<
Array
<
IAnythingQuickPickItem
>>
{
private
symbolsQuickAccess
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SymbolsQuickAccessProvider
));
protected
async
getSymbolPicks
(
query
:
IPreparedQuery
,
range
:
IRange
|
undefined
,
token
:
CancellationToken
):
Promise
<
Array
<
ISymbolsQuickPickItem
>>
{
if
(
!
query
.
value
||
// we need a value for search for
!
this
.
configuration
.
includeSymbols
||
// we need to enable symbols in search
...
...
@@ -338,7 +341,8 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
return
[];
}
return
[];
// Delegate to the existing symbols quick access
return
this
.
symbolsQuickAccess
.
getSymbolPicks
(
query
.
value
,
token
,
{
skipLocal
:
true
,
skipSorting
:
true
,
skipMatching
:
true
});
}
//#endregion
...
...
src/vs/workbench/contrib/search/browser/symbolsQuickAccess.ts
浏览文件 @
461c563f
...
...
@@ -23,9 +23,11 @@ import { IKeyMods } from 'vs/platform/quickinput/common/quickInput';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
createResourceExcludeMatcher
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
interface
ISymbolsQuickPickItem
extends
IPickerQuickAccessItem
{
score
:
FuzzyScore
;
export
interface
ISymbolsQuickPickItem
extends
IPickerQuickAccessItem
{
resource
:
URI
|
undefined
;
score
:
FuzzyScore
|
undefined
;
symbol
:
IWorkspaceSymbol
;
}
...
...
@@ -64,11 +66,11 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
return
[];
}
return
this
.
doG
etSymbolPicks
(
filter
,
token
);
return
this
.
g
etSymbolPicks
(
filter
,
token
);
});
}
private
async
doGetSymbolPicks
(
filter
:
string
,
token
:
CancellationToken
):
Promise
<
Array
<
ISymbolsQuickPickItem
>>
{
async
getSymbolPicks
(
filter
:
string
,
token
:
CancellationToken
,
options
?:
{
skipLocal
:
boolean
,
skipSorting
:
boolean
,
skipMatching
:
boolean
}
):
Promise
<
Array
<
ISymbolsQuickPickItem
>>
{
const
workspaceSymbols
=
await
getWorkspaceSymbols
(
filter
,
token
);
if
(
token
.
isCancellationRequested
)
{
return
[];
...
...
@@ -86,15 +88,13 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
const
symbolsExcludedByResource
=
new
ResourceMap
<
boolean
>
();
for
(
const
[
provider
,
symbols
]
of
workspaceSymbols
)
{
for
(
const
symbol
of
symbols
)
{
// Score by symbol label
const
symbolLabel
=
symbol
.
name
;
const
symbolScore
=
fuzzyScore
(
symbolFilter
,
symbolFilterLow
,
0
,
symbolLabel
,
symbolLabel
.
toLowerCase
(),
0
,
true
);
if
(
!
symbolScore
)
{
continue
;
if
(
options
?.
skipLocal
&&
!!
symbol
.
containerName
)
{
continue
;
// ignore local symbols if we are told so
}
const
symbolUri
=
symbol
.
location
.
uri
;
const
symbolLabel
=
symbol
.
name
;
let
containerLabel
:
string
|
undefined
=
undefined
;
if
(
symbolUri
)
{
const
containerPath
=
this
.
labelService
.
getUriLabel
(
symbolUri
,
{
relative
:
true
});
...
...
@@ -105,16 +105,27 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
}
}
// Score by container if specified
// Score (only if enabled)
let
symbolScore
:
FuzzyScore
|
undefined
=
undefined
;
let
containerScore
:
FuzzyScore
|
undefined
=
undefined
;
if
(
containerFilter
&&
containerFilterLow
)
{
if
(
containerLabel
)
{
containerScore
=
fuzzyScore
(
containerFilter
,
containerFilterLow
,
0
,
containerLabel
,
containerLabel
.
toLowerCase
(),
0
,
true
);
}
if
(
!
options
?.
skipMatching
)
{
if
(
!
containerScore
)
{
// Score by symbol label
symbolScore
=
fuzzyScore
(
symbolFilter
,
symbolFilterLow
,
0
,
symbolLabel
,
symbolLabel
.
toLowerCase
(),
0
,
true
);
if
(
!
symbolScore
)
{
continue
;
}
// Score by container if specified
if
(
containerFilter
&&
containerFilterLow
)
{
if
(
containerLabel
)
{
containerScore
=
fuzzyScore
(
containerFilter
,
containerFilterLow
,
0
,
containerLabel
,
containerLabel
.
toLowerCase
(),
0
,
true
);
}
if
(
!
containerScore
)
{
continue
;
}
}
}
// Filter out symbols that match the global resource filter
...
...
@@ -135,6 +146,7 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
symbolPicks
.
push
({
symbol
,
resource
:
symbol
.
location
.
uri
,
score
:
symbolScore
,
label
:
symbolLabelWithIcon
,
ariaLabel
:
localize
(
'
symbolAriaLabel
'
,
"
{0}, symbols picker
"
,
symbolLabel
),
...
...
@@ -160,8 +172,10 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
}
}
// Sort picks
symbolPicks
.
sort
((
symbolA
,
symbolB
)
=>
this
.
compareSymbols
(
symbolA
,
symbolB
));
// Sort picks (unless disabled)
if
(
!
options
?.
skipSorting
)
{
symbolPicks
.
sort
((
symbolA
,
symbolB
)
=>
this
.
compareSymbols
(
symbolA
,
symbolB
));
}
return
symbolPicks
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录