Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
be64126a
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,发现更多精彩内容 >>
提交
be64126a
编写于
3月 16, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quick access - wrap up goto symbol
上级
eac4cc22
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
18 deletion
+18
-18
src/vs/base/common/filters.ts
src/vs/base/common/filters.ts
+2
-2
src/vs/editor/contrib/quickAccess/gotoSymbolQuickAccess.ts
src/vs/editor/contrib/quickAccess/gotoSymbolQuickAccess.ts
+16
-16
未找到文件。
src/vs/base/common/filters.ts
浏览文件 @
be64126a
...
...
@@ -392,7 +392,7 @@ export function anyScore(pattern: string, lowPattern: string, _patternPos: numbe
//#region --- fuzzyScore ---
export
function
createMatches
(
score
:
undefined
|
FuzzyScore
):
IMatch
[]
{
export
function
createMatches
(
score
:
undefined
|
FuzzyScore
,
offset
=
0
):
IMatch
[]
{
if
(
typeof
score
===
'
undefined
'
)
{
return
[];
}
...
...
@@ -407,7 +407,7 @@ export function createMatches(score: undefined | FuzzyScore): IMatch[] {
if
(
last
&&
last
.
end
===
pos
)
{
last
.
end
=
pos
+
1
;
}
else
{
res
.
push
({
start
:
pos
,
end
:
pos
+
1
});
res
.
push
({
start
:
pos
+
offset
,
end
:
pos
+
1
+
offset
});
}
}
}
...
...
src/vs/editor/contrib/quickAccess/gotoSymbolQuickAccess.ts
浏览文件 @
be64126a
...
...
@@ -62,6 +62,10 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
}
}));
// Resolve symbols from document once and reuse this
// request for all filtering and typing then on
const
symbolsPromise
=
this
.
getDocumentSymbols
(
model
,
true
,
token
);
// Set initial picks and update on type
let
picksCts
:
CancellationTokenSource
|
undefined
=
undefined
;
const
updatePickerItems
=
async
()
=>
{
...
...
@@ -76,7 +80,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
// Collect symbol picks
picker
.
busy
=
true
;
try
{
const
items
=
await
this
.
getSymbolPicks
(
model
,
picker
.
value
.
substr
(
AbstractGotoSymbolQuickAccessProvider
.
PREFIX
.
length
).
trim
(),
picksCts
.
token
);
const
items
=
await
this
.
getSymbolPicks
(
symbolsPromise
,
picker
.
value
.
substr
(
AbstractGotoSymbolQuickAccessProvider
.
PREFIX
.
length
).
trim
(),
picksCts
.
token
);
if
(
token
.
isCancellationRequested
)
{
return
;
}
...
...
@@ -92,9 +96,17 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
updatePickerItems
();
// Reveal and decorate when active item changes
// However, ignore the very first event so that
// opening the picker is not immediately revealing
// and decorating the first entry.
let
ignoreFirstActiveEvent
=
true
;
disposables
.
add
(
picker
.
onDidChangeActive
(()
=>
{
const
[
item
]
=
picker
.
activeItems
;
if
(
item
&&
item
.
range
)
{
if
(
ignoreFirstActiveEvent
)
{
ignoreFirstActiveEvent
=
false
;
return
;
}
// Reveal
editor
.
revealRangeInCenter
(
item
.
range
.
selection
,
ScrollType
.
Smooth
);
...
...
@@ -107,10 +119,8 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
return
disposables
;
}
private
async
getSymbolPicks
(
model
:
ITextModel
,
filter
:
string
,
token
:
CancellationToken
):
Promise
<
Array
<
IGotoSymbolQuickPickItem
|
IQuickPickSeparator
>>
{
// Resolve symbols from document
const
symbols
=
await
this
.
getDocumentSymbols
(
model
,
true
,
token
);
private
async
getSymbolPicks
(
symbolsPromise
:
Promise
<
DocumentSymbol
[]
>
,
filter
:
string
,
token
:
CancellationToken
):
Promise
<
Array
<
IGotoSymbolQuickPickItem
|
IQuickPickSeparator
>>
{
const
symbols
=
await
symbolsPromise
;
if
(
token
.
isCancellationRequested
)
{
return
[];
}
...
...
@@ -138,16 +148,6 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
if
(
includeSymbol
)
{
const
labelWithIcon
=
`$(symbol-
${
SymbolKinds
.
toString
(
symbol
.
kind
)
||
'
property
'
}
)
${
label
}
`
;
// Readjust matches to account for codicons
const
labelOffset
=
labelWithIcon
.
length
-
label
.
length
;
const
matches
=
createMatches
(
score
);
if
(
matches
)
{
for
(
const
match
of
matches
)
{
match
.
start
+=
labelOffset
;
match
.
end
+=
labelOffset
;
}
}
filteredSymbolPicks
.
push
({
index
,
kind
:
symbol
.
kind
,
...
...
@@ -155,7 +155,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
label
:
labelWithIcon
,
ariaLabel
:
localize
(
'
symbolsAriaLabel
'
,
"
{0}, symbols picker
"
,
label
),
description
:
symbol
.
containerName
,
highlights
:
deprecated
?
undefined
:
{
label
:
matches
},
highlights
:
deprecated
?
undefined
:
{
label
:
createMatches
(
score
,
labelWithIcon
.
length
-
label
.
length
/* Readjust matches to account for codicons */
)
},
range
:
{
selection
:
Range
.
collapseToStart
(
symbol
.
selectionRange
),
decoration
:
symbol
.
range
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录