Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9513cab9
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,发现更多精彩内容 >>
提交
9513cab9
编写于
5月 08, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sort by position, name, kind
上级
5b14d979
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
6 deletion
+89
-6
src/vs/base/common/actions.ts
src/vs/base/common/actions.ts
+24
-1
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
.../workbench/parts/outline/electron-browser/outlinePanel.ts
+45
-3
src/vs/workbench/parts/outline/electron-browser/outlineTree.ts
...s/workbench/parts/outline/electron-browser/outlineTree.ts
+20
-2
未找到文件。
src/vs/base/common/actions.ts
浏览文件 @
9513cab9
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
export
interface
ITelemetryData
{
...
...
@@ -237,3 +237,26 @@ export class ActionRunner implements IActionRunner {
this
.
_onDidRun
.
dispose
();
}
}
export
class
RadioGroup
{
private
_disposable
:
IDisposable
;
constructor
(
readonly
actions
:
Action
[])
{
this
.
_disposable
=
combinedDisposable
(
actions
.
map
(
action
=>
{
return
action
.
onDidChange
(
e
=>
{
if
(
e
.
checked
&&
action
.
checked
)
{
for
(
const
candidate
of
actions
)
{
if
(
candidate
!==
action
)
{
candidate
.
checked
=
false
;
}
}
}
});
}));
}
dispose
():
void
{
this
.
_disposable
.
dispose
();
}
}
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
浏览文件 @
9513cab9
...
...
@@ -26,8 +26,9 @@ import { IViewOptions, ViewsViewletPanel } from 'vs/workbench/browser/parts/view
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
OneOutline
,
OutlineItem
,
getOutline
}
from
'
./outlineModel
'
;
import
{
OutlineDataSource
,
OutlineRenderer
,
OutlineItemComparator
,
OutlineItemFilter
}
from
'
./outlineTree
'
;
import
{
OutlineDataSource
,
OutlineRenderer
,
OutlineItemComparator
,
OutlineItemFilter
,
OutlineItemCompareType
}
from
'
./outlineTree
'
;
import
{
localize
}
from
'
../../../../nls
'
;
import
{
IAction
,
Action
,
RadioGroup
}
from
'
vs/base/common/actions
'
;
class
ActiveEditorOracle
{
...
...
@@ -65,6 +66,23 @@ class ActiveEditorOracle {
}
}
class
ChangeSortAction
extends
Action
{
private
static
_labels
=
{
[
OutlineItemCompareType
.
ByPosition
]:
localize
(
'
sortByPosition
'
,
"
Sort By Position
"
),
[
OutlineItemCompareType
.
ByName
]:
localize
(
'
sortByName
'
,
"
Sort By Name
"
),
[
OutlineItemCompareType
.
ByKind
]:
localize
(
'
sortByKind
'
,
"
Sort By Type
"
),
};
constructor
(
type
:
OutlineItemCompareType
,
callback
:
(
type
:
OutlineItemCompareType
)
=>
any
)
{
super
(
String
(
type
),
ChangeSortAction
.
_labels
[
type
],
null
,
true
,
()
=>
{
this
.
checked
=
true
;
callback
(
type
);
return
undefined
;
});
}
}
export
class
OutlinePanel
extends
ViewsViewletPanel
{
private
readonly
_disposables
=
new
Array
<
IDisposable
>
();
...
...
@@ -126,6 +144,23 @@ export class OutlinePanel extends ViewsViewletPanel {
return
super
.
setVisible
(
visible
);
}
getSecondaryActions
():
IAction
[]
{
let
group
=
new
RadioGroup
([
new
ChangeSortAction
(
OutlineItemCompareType
.
ByPosition
,
type
=>
this
.
_onSortTypeChanged
(
type
)),
new
ChangeSortAction
(
OutlineItemCompareType
.
ByName
,
type
=>
this
.
_onSortTypeChanged
(
type
)),
new
ChangeSortAction
(
OutlineItemCompareType
.
ByKind
,
type
=>
this
.
_onSortTypeChanged
(
type
)),
]);
group
.
actions
[
0
].
checked
=
true
;
// todo@joh persist/restore setting
return
group
.
actions
;
}
private
_onSortTypeChanged
(
type
:
OutlineItemCompareType
)
{
if
(
this
.
_treeComparator
.
type
!==
type
)
{
this
.
_treeComparator
.
type
=
type
;
this
.
_tree
.
refresh
(
undefined
,
true
);
}
}
private
_onEditor
(
editor
:
ICodeEditor
):
void
{
dispose
(
this
.
_editorDisposables
);
this
.
_editorDisposables
=
new
Array
();
...
...
@@ -135,9 +170,8 @@ export class OutlinePanel extends ViewsViewletPanel {
return
;
}
// todo@joh cancellation
// todo@joh show pending...
getOutline
(
editor
.
getModel
()).
then
(
outline
=>
{
const
promise
=
getOutline
(
editor
.
getModel
()).
then
(
outline
=>
{
let
model
=
<
OneOutline
>
this
.
_tree
.
getInput
();
let
[
first
]
=
outline
;
if
(
!
first
)
{
...
...
@@ -154,6 +188,7 @@ export class OutlinePanel extends ViewsViewletPanel {
this
.
_input
.
enable
();
this
.
_editorDisposables
.
push
(
this
.
_input
.
onDidChange
(
query
=>
{
//todo@joh `updateFilter` should return the best match and it should be focused already
model
.
updateFilter
(
query
);
this
.
_tree
.
refresh
(
undefined
,
true
);
}));
...
...
@@ -169,7 +204,14 @@ export class OutlinePanel extends ViewsViewletPanel {
}));
},
err
=>
{
//todo@joh have an error screen
console
.
error
(
err
);
});
this
.
_editorDisposables
.
push
({
dispose
()
{
promise
.
cancel
();
}
});
}
}
src/vs/workbench/parts/outline/electron-browser/outlineTree.ts
浏览文件 @
9513cab9
...
...
@@ -14,9 +14,27 @@ import { OneOutline, OutlineItem } from './outlineModel';
import
{
HighlightedLabel
}
from
'
../../../../base/browser/ui/highlightedlabel/highlightedLabel
'
;
import
{
createMatches
}
from
'
../../../../base/common/filters
'
;
export
enum
OutlineItemCompareType
{
ByPosition
,
ByName
,
ByKind
}
export
class
OutlineItemComparator
implements
ISorter
{
type
:
OutlineItemCompareType
=
OutlineItemCompareType
.
ByPosition
;
compare
(
tree
:
ITree
,
a
:
OutlineItem
,
b
:
OutlineItem
):
number
{
return
Range
.
compareRangesUsingStarts
(
a
.
symbol
.
location
.
range
,
b
.
symbol
.
location
.
range
);
switch
(
this
.
type
)
{
case
OutlineItemCompareType
.
ByKind
:
return
a
.
symbol
.
kind
-
b
.
symbol
.
kind
;
case
OutlineItemCompareType
.
ByName
:
return
a
.
symbol
.
name
.
localeCompare
(
b
.
symbol
.
name
);
case
OutlineItemCompareType
.
ByPosition
:
default
:
return
Range
.
compareRangesUsingStarts
(
a
.
symbol
.
location
.
range
,
b
.
symbol
.
location
.
range
);
}
}
}
...
...
@@ -82,7 +100,7 @@ export class OutlineRenderer implements IRenderer {
}
renderElement
(
tree
:
ITree
,
element
:
OutlineItem
,
templateId
:
string
,
template
:
OutlineItemTemplate
):
void
{
template
.
icon
.
class
List
.
add
(
symbolKindToCssClass
((
<
OutlineItem
>
element
).
symbol
.
kind
))
;
template
.
icon
.
class
Name
=
`outline-element-icon symbol-icon
${
symbolKindToCssClass
(
element
.
symbol
.
kind
)}
`
;
template
.
label
.
set
(
element
.
symbol
.
name
,
element
.
matches
?
createMatches
(
element
.
matches
[
1
])
:
[]);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录