Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8dbf25e4
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,发现更多精彩内容 >>
提交
8dbf25e4
编写于
2月 05, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove old highlighting tree
上级
881c4c42
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
3 addition
and
244 deletion
+3
-244
src/vs/platform/list/browser/listService.ts
src/vs/platform/list/browser/listService.ts
+3
-244
未找到文件。
src/vs/platform/list/browser/listService.ts
浏览文件 @
8dbf25e4
...
@@ -3,32 +3,26 @@
...
@@ -3,32 +3,26 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
addClass
,
addStandardDisposableListener
,
createStyleSheet
,
getTotalHeight
,
removeClass
}
from
'
vs/base/browser/dom
'
;
import
{
createStyleSheet
}
from
'
vs/base/browser/dom
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
IInputOptions
,
InputBox
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
IListMouseEvent
,
IListTouchEvent
,
IListRenderer
,
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IListMouseEvent
,
IListTouchEvent
,
IListRenderer
,
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IPagedRenderer
,
PagedList
}
from
'
vs/base/browser/ui/list/listPaging
'
;
import
{
IPagedRenderer
,
PagedList
}
from
'
vs/base/browser/ui/list/listPaging
'
;
import
{
DefaultStyleController
,
IListOptions
,
IMultipleSelectionController
,
IOpenController
,
isSelectionRangeChangeEvent
,
isSelectionSingleChangeEvent
,
List
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
DefaultStyleController
,
IListOptions
,
IMultipleSelectionController
,
IOpenController
,
isSelectionRangeChangeEvent
,
isSelectionSingleChangeEvent
,
List
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
canceled
,
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
FuzzyScore
}
from
'
vs/base/common/filters
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
combinedDisposable
,
Disposable
,
dispose
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
combinedDisposable
,
Disposable
,
dispose
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ScrollbarVisibility
}
from
'
vs/base/common/scrollable
'
;
import
{
ScrollbarVisibility
}
from
'
vs/base/common/scrollable
'
;
import
{
isUndefinedOrNull
}
from
'
vs/base/common/types
'
;
import
{
isUndefinedOrNull
}
from
'
vs/base/common/types
'
;
import
{
I
Filter
,
I
Tree
,
ITreeConfiguration
,
ITreeOptions
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ITree
,
ITreeConfiguration
,
ITreeOptions
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ClickBehavior
,
DefaultController
,
DefaultTreestyler
,
IControllerOptions
,
OpenMode
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
ClickBehavior
,
DefaultController
,
DefaultTreestyler
,
IControllerOptions
,
OpenMode
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Extensions
as
ConfigurationExtensions
,
IConfigurationRegistry
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
Extensions
as
ConfigurationExtensions
,
IConfigurationRegistry
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
ContextKeyExpr
,
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ContextKeyExpr
,
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
createDecorator
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
createDecorator
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
attach
InputBoxStyler
,
attach
ListStyler
,
computeStyles
,
defaultListStyles
}
from
'
vs/platform/theme/common/styler
'
;
import
{
attachListStyler
,
computeStyles
,
defaultListStyles
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
InputFocusedContextKey
}
from
'
vs/platform/workbench/common/contextkeys
'
;
import
{
InputFocusedContextKey
}
from
'
vs/platform/workbench/common/contextkeys
'
;
import
{
ObjectTree
,
IObjectTreeOptions
}
from
'
vs/base/browser/ui/tree/objectTree
'
;
import
{
ObjectTree
,
IObjectTreeOptions
}
from
'
vs/base/browser/ui/tree/objectTree
'
;
...
@@ -722,241 +716,6 @@ export class TreeResourceNavigator2<T, TFilterData> extends Disposable {
...
@@ -722,241 +716,6 @@ export class TreeResourceNavigator2<T, TFilterData> extends Disposable {
}
}
}
}
export
interface
IHighlighter
{
getHighlights
(
tree
:
ITree
,
element
:
any
,
pattern
:
string
):
FuzzyScore
;
getHighlightsStorageKey
?(
element
:
any
):
any
;
}
export
interface
IHighlightingTreeConfiguration
extends
ITreeConfiguration
{
highlighter
:
IHighlighter
;
}
export
interface
IHighlightingTreeOptions
extends
ITreeOptions
{
filterOnType
?:
boolean
;
}
export
class
HighlightingTreeController
extends
WorkbenchTreeController
{
constructor
(
options
:
IControllerOptions
,
private
readonly
onType
:
()
=>
any
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IKeybindingService
private
readonly
_keybindingService
:
IKeybindingService
,
)
{
super
(
options
,
configurationService
);
}
onKeyDown
(
tree
:
ITree
,
event
:
IKeyboardEvent
)
{
let
handled
=
super
.
onKeyDown
(
tree
,
event
);
if
(
handled
)
{
return
true
;
}
if
(
this
.
upKeyBindingDispatcher
.
has
(
event
.
keyCode
))
{
return
false
;
}
if
(
this
.
_keybindingService
.
mightProducePrintableCharacter
(
event
))
{
this
.
onType
();
return
true
;
}
return
false
;
}
}
class
HightlightsFilter
implements
IFilter
{
static
add
(
config
:
ITreeConfiguration
,
options
:
IHighlightingTreeOptions
):
ITreeConfiguration
{
const
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
;
protected
readonly
inputContainer
:
HTMLElement
;
protected
readonly
input
:
InputBox
;
protected
readonly
highlighter
:
IHighlighter
;
protected
readonly
highlights
:
Map
<
any
,
FuzzyScore
>
;
private
readonly
_onDidStartFilter
:
Emitter
<
this
>
;
readonly
onDidStartFiltering
:
Event
<
this
>
;
constructor
(
parent
:
HTMLElement
,
treeConfiguration
:
IHighlightingTreeConfiguration
,
treeOptions
:
IHighlightingTreeOptions
,
listOptions
:
IInputOptions
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IContextViewService
contextViewService
:
IContextViewService
,
@
IListService
listService
:
IListService
,
@
IThemeService
themeService
:
IThemeService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
// build html skeleton
const
container
=
document
.
createElement
(
'
div
'
);
container
.
className
=
'
highlighting-tree
'
;
const
inputContainer
=
document
.
createElement
(
'
div
'
);
inputContainer
.
className
=
'
input
'
;
const
treeContainer
=
document
.
createElement
(
'
div
'
);
treeContainer
.
className
=
'
tree
'
;
container
.
appendChild
(
inputContainer
);
container
.
appendChild
(
treeContainer
);
parent
.
appendChild
(
container
);
// create tree
treeConfiguration
.
controller
=
treeConfiguration
.
controller
||
instantiationService
.
createInstance
(
HighlightingTreeController
,
{},
()
=>
this
.
onTypeInTree
());
super
(
treeContainer
,
HightlightsFilter
.
add
(
treeConfiguration
,
treeOptions
),
treeOptions
,
contextKeyService
,
listService
,
themeService
,
instantiationService
,
configurationService
);
this
.
highlighter
=
treeConfiguration
.
highlighter
;
this
.
highlights
=
new
Map
<
any
,
FuzzyScore
>
();
this
.
domNode
=
container
;
addClass
(
this
.
domNode
,
'
inactive
'
);
// create input
this
.
inputContainer
=
inputContainer
;
this
.
input
=
new
InputBox
(
inputContainer
,
contextViewService
,
listOptions
);
this
.
input
.
setEnabled
(
false
);
this
.
input
.
onDidChange
(
this
.
updateHighlights
,
this
,
this
.
disposables
);
this
.
disposables
.
push
(
attachInputBoxStyler
(
this
.
input
,
themeService
));
this
.
disposables
.
push
(
this
.
input
);
this
.
disposables
.
push
(
addStandardDisposableListener
(
this
.
input
.
inputElement
,
'
keydown
'
,
event
=>
{
//todo@joh make this command/context-key based
switch
(
event
.
keyCode
)
{
case
KeyCode
.
UpArrow
:
case
KeyCode
.
DownArrow
:
case
KeyCode
.
Tab
:
this
.
domFocus
();
event
.
preventDefault
();
break
;
case
KeyCode
.
Enter
:
this
.
setSelection
(
this
.
getSelection
());
event
.
preventDefault
();
break
;
case
KeyCode
.
Escape
:
this
.
input
.
value
=
''
;
this
.
domFocus
();
event
.
preventDefault
();
break
;
}
}));
this
.
_onDidStartFilter
=
new
Emitter
<
this
>
();
this
.
onDidStartFiltering
=
this
.
_onDidStartFilter
.
event
;
this
.
disposables
.
push
(
this
.
_onDidStartFilter
);
}
setInput
(
element
:
any
):
Promise
<
any
>
{
this
.
input
.
setEnabled
(
false
);
return
super
.
setInput
(
element
).
then
(
value
=>
{
if
(
!
this
.
input
.
inputElement
)
{
// has been disposed in the meantime -> cancel
return
Promise
.
reject
(
canceled
());
}
this
.
input
.
setEnabled
(
true
);
return
value
;
});
}
layout
(
height
?:
number
,
width
?:
number
):
void
{
this
.
input
.
layout
();
super
.
layout
(
typeof
height
!==
'
number
'
||
isNaN
(
height
)
?
height
:
height
-
getTotalHeight
(
this
.
inputContainer
),
width
);
}
private
onTypeInTree
():
void
{
removeClass
(
this
.
domNode
,
'
inactive
'
);
this
.
input
.
focus
();
this
.
layout
();
this
.
_onDidStartFilter
.
fire
(
this
);
}
private
lastSelection
:
any
[];
private
updateHighlights
(
pattern
:
string
):
void
{
// remember old selection
let
defaultSelection
:
any
[]
=
[];
if
(
!
this
.
lastSelection
&&
pattern
)
{
this
.
lastSelection
=
this
.
getSelection
();
}
else
if
(
this
.
lastSelection
&&
!
pattern
)
{
defaultSelection
=
this
.
lastSelection
;
this
.
lastSelection
=
[];
}
let
topElement
:
any
;
if
(
pattern
)
{
let
nav
=
this
.
getNavigator
(
undefined
,
false
);
let
topScore
:
FuzzyScore
|
undefined
;
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
)
{
this
.
reveal
(
topElement
,
0.5
).
then
(
_
=>
{
this
.
setSelection
([
topElement
],
this
);
this
.
setFocus
(
topElement
,
this
);
});
}
else
{
this
.
setSelection
(
defaultSelection
,
this
);
}
},
onUnexpectedError
);
}
isHighlighterScoring
():
boolean
{
return
this
.
highlights
.
size
>
0
;
}
getHighlighterScore
(
element
:
any
):
FuzzyScore
|
undefined
{
return
this
.
highlights
.
get
(
this
.
_getHighlightsStorageKey
(
element
));
}
private
_getHighlightsStorageKey
(
element
:
any
):
any
{
return
typeof
this
.
highlighter
.
getHighlightsStorageKey
===
'
function
'
?
this
.
highlighter
.
getHighlightsStorageKey
(
element
)
:
element
;
}
}
function
createKeyboardNavigationEventFilter
(
container
:
HTMLElement
,
keybindingService
:
IKeybindingService
):
IKeyboardNavigationEventFilter
{
function
createKeyboardNavigationEventFilter
(
container
:
HTMLElement
,
keybindingService
:
IKeybindingService
):
IKeyboardNavigationEventFilter
{
let
inChord
=
false
;
let
inChord
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录