Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
84a0f5df
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,发现更多精彩内容 >>
提交
84a0f5df
编写于
8月 23, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #56983
上级
c2f65202
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
40 deletion
+75
-40
src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts
src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts
+42
-12
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
+33
-28
未找到文件。
src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts
浏览文件 @
84a0f5df
...
...
@@ -9,40 +9,41 @@ import * as dom from 'vs/base/browser/dom';
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
BreadcrumbsItem
,
BreadcrumbsWidget
,
IBreadcrumbsItemEvent
}
from
'
vs/base/browser/ui/breadcrumbs/breadcrumbsWidget
'
;
import
{
IconLabel
}
from
'
vs/base/browser/ui/iconLabel/iconLabel
'
;
import
{
tail
}
from
'
vs/base/common/arrays
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
combinedDisposable
,
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
isEqual
}
from
'
vs/base/common/resources
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
'
vs/css!./media/breadcrumbscontrol
'
;
import
{
ICodeEditor
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ICodeEditorViewState
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
symbolKindToCssClass
}
from
'
vs/editor/common/modes
'
;
import
{
OutlineElement
,
OutlineGroup
,
OutlineModel
,
TreeElement
}
from
'
vs/editor/contrib/documentSymbols/outlineModel
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
MenuId
,
MenuRegistry
}
from
'
vs/platform/actions/common/actions
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ContextKeyExpr
,
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
FileKind
,
IFileService
,
IFileStat
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingsRegistry
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IListService
,
WorkbenchListFocusContextKey
}
from
'
vs/platform/list/browser/listService
'
;
import
{
IQuickOpenService
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
{
ColorIdentifier
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
attachBreadcrumbsStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
FileLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
BreadcrumbsConfig
,
IBreadcrumbsService
}
from
'
vs/workbench/browser/parts/editor/breadcrumbs
'
;
import
{
BreadcrumbElement
,
EditorBreadcrumbsModel
,
FileElement
}
from
'
vs/workbench/browser/parts/editor/breadcrumbsModel
'
;
import
{
createBreadcrumbsPicker
,
BreadcrumbsPicker
}
from
'
vs/workbench/browser/parts/editor/breadcrumbsPicker
'
;
import
{
BreadcrumbsPicker
,
create
BreadcrumbsPicker
}
from
'
vs/workbench/browser/parts/editor/breadcrumbsPicker
'
;
import
{
EditorGroupView
}
from
'
vs/workbench/browser/parts/editor/editorGroupView
'
;
import
{
IEditorService
,
SIDE_GROUP
,
SIDE_GROUP_TYPE
,
ACTIVE_GROUP_TYPE
,
ACTIVE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
ACTIVE_GROUP
,
ACTIVE_GROUP_TYPE
,
IEditorService
,
SIDE_GROUP
,
SIDE_GROUP_TYPE
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
MenuRegistry
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
tail
}
from
'
vs/base/common/arrays
'
;
import
{
WorkbenchListFocusContextKey
,
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
ColorIdentifier
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
URI
from
'
vs/base/common/uri
'
;
class
Item
extends
BreadcrumbsItem
{
...
...
@@ -280,17 +281,42 @@ export class BreadcrumbsControl {
// show picker
let
picker
:
BreadcrumbsPicker
;
let
editor
=
this
.
_editorGroup
.
activeControl
.
getControl
()
as
ICodeEditor
;
let
editorDecorations
:
string
[]
=
[];
let
editorViewState
:
ICodeEditorViewState
;
this
.
_contextViewService
.
showContextView
({
render
:
(
parent
:
HTMLElement
)
=>
{
picker
=
createBreadcrumbsPicker
(
this
.
_instantiationService
,
parent
,
element
);
let
listener
=
picker
.
onDidPickElement
(
data
=>
{
let
selectListener
=
picker
.
onDidPickElement
(
data
=>
{
if
(
data
.
target
)
{
editorViewState
=
undefined
;
}
this
.
_contextViewService
.
hideContextView
(
this
);
this
.
_revealInEditor
(
event
,
data
.
target
,
this
.
_getEditorGroup
(
data
.
payload
&&
data
.
payload
.
originalEvent
));
});
let
focusListener
=
picker
.
onDidFocusElement
(
data
=>
{
if
(
!
(
data
.
target
instanceof
OutlineElement
))
{
return
;
}
if
(
!
editorViewState
)
{
editorViewState
=
editor
.
saveViewState
();
}
const
{
symbol
}
=
data
.
target
;
editor
.
revealRangeInCenter
(
symbol
.
range
,
ScrollType
.
Smooth
);
editorDecorations
=
editor
.
deltaDecorations
(
editorDecorations
,
[{
range
:
symbol
.
range
,
options
:
{
className
:
'
rangeHighlight
'
,
isWholeLine
:
true
}
}]);
});
this
.
_breadcrumbsPickerShowing
=
true
;
this
.
_updateCkBreadcrumbsActive
();
return
combinedDisposable
([
l
istener
,
picker
]);
return
combinedDisposable
([
selectListener
,
focusL
istener
,
picker
]);
},
getAnchor
:
()
=>
{
let
maxInnerWidth
=
window
.
innerWidth
-
8
/*a little less the the full widget*/
;
...
...
@@ -320,6 +346,10 @@ export class BreadcrumbsControl {
return
{
x
,
y
};
},
onHide
:
(
data
)
=>
{
editor
.
deltaDecorations
(
editorDecorations
,
[]);
if
(
editorViewState
)
{
editor
.
restoreViewState
(
editorViewState
);
}
this
.
_breadcrumbsPickerShowing
=
false
;
this
.
_updateCkBreadcrumbsActive
();
if
(
data
===
this
)
{
...
...
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
浏览文件 @
84a0f5df
...
...
@@ -7,30 +7,29 @@
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
compareFileNames
}
from
'
vs/base/common/comparers
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
createMatches
,
FuzzyScore
,
fuzzyScore
}
from
'
vs/base/common/filters
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dirname
,
isEqual
,
basename
}
from
'
vs/base/common/resources
'
;
import
{
basename
,
dirname
,
isEqual
}
from
'
vs/base/common/resources
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDataSource
,
I
Renderer
,
ISelectionEvent
,
ISorter
,
ITree
,
IFilter
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
IDataSource
,
I
Filter
,
IRenderer
,
ISorter
,
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
'
vs/css!./media/breadcrumbscontrol
'
;
import
{
OutlineElement
,
OutlineModel
,
TreeElement
}
from
'
vs/editor/contrib/documentSymbols/outlineModel
'
;
import
{
OutlineDataSource
,
OutlineItemComparator
,
OutlineRenderer
}
from
'
vs/editor/contrib/documentSymbols/outlineTree
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
FileKind
,
IFileService
,
IFileStat
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
,
IConstructorSignature1
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
HighlightingWorkbenchTree
,
IHighlightingTreeConfiguration
,
IHighlightingRenderer
}
from
'
vs/platform/list/browser/listService
'
;
import
{
IConstructorSignature1
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
HighlightingWorkbenchTree
,
IHighlightingRenderer
,
IHighlightingTreeConfiguration
}
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
'
;
import
{
FileLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
BreadcrumbElement
,
FileElement
}
from
'
vs/workbench/browser/parts/editor/breadcrumbsModel
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
breadcrumbsPickerBackground
,
widgetShadow
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
FuzzyScore
,
createMatches
,
fuzzyScore
}
from
'
vs/base/common/filters
'
;
import
{
IWorkspaceContextService
,
IWorkspace
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
BreadcrumbsConfig
}
from
'
vs/workbench/browser/parts/editor/breadcrumbs
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
}
from
'
vs/base/common/paths
'
;
import
{
BreadcrumbElement
,
FileElement
}
from
'
vs/workbench/browser/parts/editor/breadcrumbsModel
'
;
export
function
createBreadcrumbsPicker
(
instantiationService
:
IInstantiationService
,
parent
:
HTMLElement
,
element
:
BreadcrumbElement
):
BreadcrumbsPicker
{
let
ctor
:
IConstructorSignature1
<
HTMLElement
,
BreadcrumbsPicker
>
=
element
instanceof
FileElement
?
BreadcrumbsFilePicker
:
BreadcrumbsOutlinePicker
;
...
...
@@ -49,6 +48,9 @@ export abstract class BreadcrumbsPicker {
private
readonly
_onDidPickElement
=
new
Emitter
<
{
target
:
any
,
payload
:
any
}
>
();
readonly
onDidPickElement
:
Event
<
{
target
:
any
,
payload
:
any
}
>
=
this
.
_onDidPickElement
.
event
;
private
readonly
_onDidFocusElement
=
new
Emitter
<
{
target
:
any
,
payload
:
any
}
>
();
readonly
onDidFocusElement
:
Event
<
{
target
:
any
,
payload
:
any
}
>
=
this
.
_onDidFocusElement
.
event
;
constructor
(
parent
:
HTMLElement
,
@
IInstantiationService
protected
readonly
_instantiationService
:
IInstantiationService
,
...
...
@@ -87,13 +89,18 @@ export abstract class BreadcrumbsPicker {
);
this
.
_disposables
.
push
(
this
.
_tree
.
onDidChangeSelection
(
e
=>
{
if
(
e
.
payload
!==
this
.
_tree
)
{
const
target
=
this
.
_getTargetFromSelectionEvent
(
e
);
if
(
!
target
)
{
return
;
const
target
=
this
.
_getTargetFromEvent
(
e
.
selection
[
0
],
e
.
payload
);
if
(
target
)
{
setTimeout
(
_
=>
{
// need to debounce here because this disposes the tree and the tree doesn't like to be disposed on click
this
.
_onDidPickElement
.
fire
({
target
,
payload
:
e
.
payload
});
},
0
);
}
setTimeout
(
_
=>
{
// need to debounce here because this disposes the tree and the tree doesn't like to be disposed on click
this
.
_onDidPickElement
.
fire
({
target
,
payload
:
e
.
payload
});
},
0
);
}
}));
this
.
_disposables
.
push
(
this
.
_tree
.
onDidChangeFocus
(
e
=>
{
const
target
=
this
.
_getTargetFromEvent
(
e
.
focus
,
e
.
payload
);
if
(
target
)
{
this
.
_onDidFocusElement
.
fire
({
target
,
payload
:
e
.
payload
});
}
}));
...
...
@@ -147,7 +154,7 @@ export abstract class BreadcrumbsPicker {
protected
abstract
_getInput
(
input
:
BreadcrumbElement
):
any
;
protected
abstract
_getInitialSelection
(
tree
:
ITree
,
input
:
BreadcrumbElement
):
any
;
protected
abstract
_completeTreeConfiguration
(
config
:
IHighlightingTreeConfiguration
):
IHighlightingTreeConfiguration
;
protected
abstract
_getTargetFrom
SelectionEvent
(
e
:
ISelectionEvent
):
any
|
undefined
;
protected
abstract
_getTargetFrom
Event
(
element
:
any
,
payload
:
any
):
any
|
undefined
;
}
//#region - Files
...
...
@@ -376,10 +383,9 @@ export class BreadcrumbsFilePicker extends BreadcrumbsPicker {
return
config
;
}
protected
_getTargetFromSelectionEvent
(
e
:
ISelectionEvent
):
any
|
undefined
{
let
[
first
]
=
e
.
selection
;
if
(
first
&&
!
IWorkspaceFolder
.
isIWorkspaceFolder
(
first
)
&&
!
(
first
as
IFileStat
).
isDirectory
)
{
return
new
FileElement
((
first
as
IFileStat
).
resource
,
FileKind
.
FILE
);
protected
_getTargetFromEvent
(
element
:
any
,
_payload
:
any
):
any
|
undefined
{
if
(
element
&&
!
IWorkspaceFolder
.
isIWorkspaceFolder
(
element
)
&&
!
(
element
as
IFileStat
).
isDirectory
)
{
return
new
FileElement
((
element
as
IFileStat
).
resource
,
FileKind
.
FILE
);
}
}
}
...
...
@@ -415,13 +421,12 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker {
return
config
;
}
protected
_getTargetFrom
SelectionEvent
(
e
:
ISelectionEvent
):
any
|
undefined
{
if
(
e
.
payload
&&
e
.
payload
.
didClickOnTwistie
)
{
protected
_getTargetFrom
Event
(
element
:
any
,
payload
:
any
):
any
|
undefined
{
if
(
payload
&&
payload
.
didClickOnTwistie
)
{
return
;
}
let
[
first
]
=
e
.
selection
;
if
(
first
instanceof
OutlineElement
)
{
return
first
;
if
(
element
instanceof
OutlineElement
)
{
return
element
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录