Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
95e4df26
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,发现更多精彩内容 >>
提交
95e4df26
编写于
8月 23, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add filtering to breadcrumbs picker, #55004
上级
ebc9f5cd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
27 deletion
+85
-27
src/vs/platform/list/browser/listService.ts
src/vs/platform/list/browser/listService.ts
+63
-16
src/vs/workbench/browser/parts/editor/breadcrumbs.ts
src/vs/workbench/browser/parts/editor/breadcrumbs.ts
+13
-7
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
+9
-4
未找到文件。
src/vs/platform/list/browser/listService.ts
浏览文件 @
95e4df26
...
...
@@ -18,7 +18,7 @@ import { combinedDisposable, Disposable, dispose, IDisposable, toDisposable } fr
import
{
ScrollbarVisibility
}
from
'
vs/base/common/scrollable
'
;
import
{
isUndefinedOrNull
}
from
'
vs/base/common/types
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ITree
,
ITreeConfiguration
,
ITreeOptions
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
I
Filter
,
I
Tree
,
ITreeConfiguration
,
ITreeOptions
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ClickBehavior
,
DefaultController
,
DefaultTreestyler
,
IControllerOptions
,
OpenMode
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
localize
}
from
'
vs/nls
'
;
...
...
@@ -572,6 +572,10 @@ export interface IHighlightingTreeConfiguration extends ITreeConfiguration {
highlighter
:
IHighlighter
;
}
export
interface
IHighlightingTreeOptions
extends
ITreeOptions
{
filterOnType
?:
boolean
;
}
export
class
HighlightingTreeController
extends
WorkbenchTreeController
{
constructor
(
...
...
@@ -599,6 +603,41 @@ export class HighlightingTreeController extends WorkbenchTreeController {
}
}
class
HightlightsFilter
implements
IFilter
{
static
add
(
config
:
ITreeConfiguration
,
options
:
IHighlightingTreeOptions
):
ITreeConfiguration
{
let
myFilter
=
new
HightlightsFilter
();
myFilter
.
enabled
=
options
.
filterOnType
;
if
(
!
config
.
filter
)
{
config
.
filter
=
myFilter
;
}
else
{
let
otherFilter
=
config
.
filter
;
config
.
filter
=
{
isVisible
(
tree
:
ITree
,
element
:
any
):
boolean
{
return
myFilter
.
isVisible
(
tree
,
element
)
&&
otherFilter
.
isVisible
(
tree
,
element
);
}
};
}
return
config
;
}
enabled
:
boolean
=
true
;
isVisible
(
tree
:
ITree
,
element
:
any
):
boolean
{
if
(
!
this
.
enabled
)
{
return
true
;
}
let
tree2
=
(
tree
as
HighlightingWorkbenchTree
);
if
(
!
tree2
.
isHighlighterScoring
())
{
return
true
;
}
if
(
tree2
.
getHighlighterScore
(
element
))
{
return
true
;
}
return
false
;
}
}
export
class
HighlightingWorkbenchTree
extends
WorkbenchTree
{
protected
readonly
domNode
:
HTMLElement
;
...
...
@@ -611,7 +650,7 @@ export class HighlightingWorkbenchTree extends WorkbenchTree {
constructor
(
parent
:
HTMLElement
,
treeConfiguration
:
IHighlightingTreeConfiguration
,
treeOptions
:
ITreeOptions
,
treeOptions
:
I
Highlighting
TreeOptions
,
listOptions
:
IInputOptions
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IContextViewService
contextViewService
:
IContextViewService
,
...
...
@@ -633,7 +672,7 @@ export class HighlightingWorkbenchTree extends WorkbenchTree {
// create tree
treeConfiguration
.
controller
=
treeConfiguration
.
controller
||
instantiationService
.
createInstance
(
HighlightingTreeController
,
{},
()
=>
this
.
onTypeInTree
());
super
(
treeContainer
,
treeConfiguration
,
treeOptions
,
contextKeyService
,
listService
,
themeService
,
instantiationService
,
configurationService
);
super
(
treeContainer
,
HightlightsFilter
.
add
(
treeConfiguration
,
treeOptions
)
,
treeOptions
,
contextKeyService
,
listService
,
themeService
,
instantiationService
,
configurationService
);
this
.
highlighter
=
treeConfiguration
.
highlighter
;
this
.
highlights
=
new
Map
<
any
,
FuzzyScore
>
();
...
...
@@ -705,34 +744,42 @@ export class HighlightingWorkbenchTree extends WorkbenchTree {
this
.
lastSelection
=
[];
}
let
nav
=
this
.
getNavigator
(
undefined
,
false
);
let
topScore
:
FuzzyScore
;
let
topElement
:
any
;
while
(
nav
.
next
())
{
let
element
=
nav
.
current
();
let
score
=
this
.
highlighter
.
getHighlights
(
this
,
element
,
pattern
);
this
.
highlights
.
set
(
this
.
_getHighlightsStorageKey
(
element
),
score
);
element
.
foo
=
1
;
if
(
!
topScore
||
score
&&
topScore
[
0
]
<
score
[
0
])
{
topScore
=
score
;
topElement
=
element
;
if
(
pattern
)
{
let
nav
=
this
.
getNavigator
(
undefined
,
false
);
let
topScore
:
FuzzyScore
;
while
(
nav
.
next
())
{
let
element
=
nav
.
current
();
let
score
=
this
.
highlighter
.
getHighlights
(
this
,
element
,
pattern
);
this
.
highlights
.
set
(
this
.
_getHighlightsStorageKey
(
element
),
score
);
element
.
foo
=
1
;
if
(
!
topScore
||
score
&&
topScore
[
0
]
<
score
[
0
])
{
topScore
=
score
;
topElement
=
element
;
}
}
}
else
{
// no pattern, clear highlights
this
.
highlights
.
clear
();
}
this
.
refresh
().
then
(()
=>
{
if
(
topElement
&&
pattern
)
{
if
(
topElement
)
{
this
.
reveal
(
topElement
,
.
5
).
then
(
_
=>
{
this
.
setSelection
([
topElement
],
this
);
this
.
setFocus
(
topElement
,
this
);
});
}
else
{
this
.
setSelection
(
defaultSelection
,
this
);
this
.
highlights
.
clear
();
}
},
onUnexpectedError
);
}
getHighlights
(
element
:
any
):
FuzzyScore
{
isHighlighterScoring
():
boolean
{
return
this
.
highlights
.
size
>
0
;
}
getHighlighterScore
(
element
:
any
):
FuzzyScore
{
return
this
.
highlights
.
get
(
this
.
_getHighlightsStorageKey
(
element
));
}
...
...
src/vs/workbench/browser/parts/editor/breadcrumbs.ts
浏览文件 @
95e4df26
...
...
@@ -6,16 +6,16 @@
'
use strict
'
;
import
{
BreadcrumbsWidget
}
from
'
vs/base/browser/ui/breadcrumbs/breadcrumbsWidget
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
GroupIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IConfigurationOverrides
,
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Extensions
,
IConfigurationRegistry
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IConfigurationService
,
IConfigurationOverrides
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IConfigurationRegistry
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
GroupIdentifier
}
from
'
vs/workbench/common/editor
'
;
export
const
IBreadcrumbsService
=
createDecorator
<
IBreadcrumbsService
>
(
'
IEditorBreadcrumbsService
'
);
...
...
@@ -72,6 +72,7 @@ export abstract class BreadcrumbsConfig<T> {
static
UseQuickPick
=
BreadcrumbsConfig
.
_stub
<
boolean
>
(
'
breadcrumbs.useQuickPick
'
);
static
FilePath
=
BreadcrumbsConfig
.
_stub
<
'
on
'
|
'
off
'
|
'
last
'
>
(
'
breadcrumbs.filePath
'
);
static
SymbolPath
=
BreadcrumbsConfig
.
_stub
<
'
on
'
|
'
off
'
|
'
last
'
>
(
'
breadcrumbs.symbolPath
'
);
static
FilterOnType
=
BreadcrumbsConfig
.
_stub
<
boolean
>
(
'
breadcrumbs.filterOnType
'
);
static
FileExcludes
=
BreadcrumbsConfig
.
_stub
<
glob
.
IExpression
>
(
'
files.exclude
'
);
...
...
@@ -143,6 +144,11 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfigurat
localize
(
'
symbolpath.last
'
,
"
Only show the current symbol in the breadcrumbs view.
"
),
]
},
'
breadcrumbs.filterOnType
'
:
{
description
:
localize
(
'
filterOnType
'
,
"
Controls whether the breadcrumb picker filters or highlights when typing.
"
),
type
:
'
boolean
'
,
default
:
false
},
}
});
...
...
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
浏览文件 @
95e4df26
...
...
@@ -23,7 +23,7 @@ import { localize } from 'vs/nls';
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
FileKind
,
IFileService
,
IFileStat
}
from
'
vs/platform/files/common/files
'
;
import
{
IConstructorSignature1
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
HighlightingWorkbenchTree
,
IHighlighter
,
IHighlightingTreeConfiguration
}
from
'
vs/platform/list/browser/listService
'
;
import
{
HighlightingWorkbenchTree
,
IHighlighter
,
IHighlightingTreeConfiguration
,
IHighlightingTreeOptions
}
from
'
vs/platform/list/browser/listService
'
;
import
{
breadcrumbsPickerBackground
,
widgetShadow
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IWorkspace
,
IWorkspaceContextService
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
...
...
@@ -55,6 +55,7 @@ export abstract class BreadcrumbsPicker {
parent
:
HTMLElement
,
@
IInstantiationService
protected
readonly
_instantiationService
:
IInstantiationService
,
@
IThemeService
protected
readonly
_themeService
:
IThemeService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
)
{
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
className
=
'
monaco-breadcrumbs-picker show-file-icons
'
;
...
...
@@ -79,12 +80,15 @@ export abstract class BreadcrumbsPicker {
this
.
_treeContainer
.
style
.
boxShadow
=
`0px 5px 8px
${
this
.
_themeService
.
getTheme
().
getColor
(
widgetShadow
)}
`
;
this
.
_domNode
.
appendChild
(
this
.
_treeContainer
);
const
filterConfig
=
BreadcrumbsConfig
.
FilterOnType
.
bindTo
(
this
.
_configurationService
);
this
.
_disposables
.
push
(
filterConfig
);
const
treeConifg
=
this
.
_completeTreeConfiguration
({
dataSource
:
undefined
,
renderer
:
undefined
,
highlighter
:
undefined
});
this
.
_tree
=
this
.
_instantiationService
.
createInstance
(
HighlightingWorkbenchTree
,
this
.
_treeContainer
,
treeConifg
,
{
useShadows
:
false
},
<
IHighlightingTreeOptions
>
{
useShadows
:
false
,
filterOnType
:
filterConfig
.
getValue
()
},
{
placeholder
:
localize
(
'
placeholder
'
,
"
Find
"
)
}
);
this
.
_disposables
.
push
(
this
.
_tree
.
onDidChangeSelection
(
e
=>
{
...
...
@@ -302,7 +306,7 @@ export class FileRenderer implements IRenderer {
fileKind
,
hidePath
:
true
,
fileDecorations
:
fileDecorations
,
matches
:
createMatches
((
tree
as
HighlightingWorkbenchTree
).
getHighlight
s
(
element
)),
matches
:
createMatches
((
tree
as
HighlightingWorkbenchTree
).
getHighlight
erScore
(
element
)),
extraClasses
:
[
'
picker-item
'
]
});
}
...
...
@@ -335,9 +339,10 @@ export class BreadcrumbsFilePicker extends BreadcrumbsPicker {
parent
:
HTMLElement
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IThemeService
themeService
:
IThemeService
,
@
IConfigurationService
configService
:
IConfigurationService
,
@
IWorkspaceContextService
private
readonly
_workspaceService
:
IWorkspaceContextService
,
)
{
super
(
parent
,
instantiationService
,
themeService
);
super
(
parent
,
instantiationService
,
themeService
,
configService
);
}
protected
_getInput
(
input
:
BreadcrumbElement
):
any
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录