Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7fda0363
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,发现更多精彩内容 >>
提交
7fda0363
编写于
5月 14, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
persist user selection for 'follow cursor'-mode and 'sort by'-choice
上级
3fce6167
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
13 deletion
+74
-13
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
.../workbench/parts/outline/electron-browser/outlinePanel.ts
+71
-12
src/vs/workbench/parts/outline/electron-browser/outlineTree.ts
...s/workbench/parts/outline/electron-browser/outlineTree.ts
+3
-1
未找到文件。
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
浏览文件 @
7fda0363
...
...
@@ -39,6 +39,8 @@ import LanguageFeatureRegistry from '../../../../editor/common/modes/languageFea
import
{
OutlineItem
,
OutlineItemGroup
,
OutlineModel
,
getOutline
}
from
'
./outlineModel
'
;
import
{
OutlineController
,
OutlineDataSource
,
OutlineItemComparator
,
OutlineItemCompareType
,
OutlineItemFilter
,
OutlineRenderer
,
OutlineTreeState
}
from
'
./outlineTree
'
;
import
{
CollapseAction
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
Emitter
}
from
'
../../../../base/common/event
'
;
import
{
IStorageService
,
StorageScope
}
from
'
../../../../platform/storage/common/storage
'
;
class
RequestOracle
{
...
...
@@ -102,11 +104,62 @@ class SimpleToggleAction extends Action {
}
}
class
OutlineState
{
private
_followCursor
=
false
;
private
_sortBy
=
OutlineItemCompareType
.
ByKind
;
private
_onDidChange
=
new
Emitter
<
{
followCursor
?:
boolean
,
sortBy
?:
boolean
}
>
();
readonly
onDidChange
=
this
.
_onDidChange
.
event
;
set
followCursor
(
value
:
boolean
)
{
if
(
value
!==
this
.
_followCursor
)
{
this
.
_followCursor
=
value
;
this
.
_onDidChange
.
fire
({
followCursor
:
true
});
}
}
get
followCursor
():
boolean
{
return
this
.
_followCursor
;
}
set
sortBy
(
value
:
OutlineItemCompareType
)
{
if
(
value
!==
this
.
_sortBy
)
{
this
.
_sortBy
=
value
;
this
.
_onDidChange
.
fire
({
sortBy
:
true
});
}
}
get
sortBy
():
OutlineItemCompareType
{
return
this
.
_sortBy
;
}
persist
(
storageService
:
IStorageService
):
void
{
storageService
.
store
(
'
outline/state
'
,
JSON
.
stringify
({
followCursor
:
this
.
followCursor
,
sortBy
:
this
.
sortBy
}),
StorageScope
.
WORKSPACE
);
}
restore
(
storageService
:
IStorageService
):
void
{
let
raw
=
storageService
.
get
(
'
outline/state
'
,
StorageScope
.
WORKSPACE
);
if
(
!
raw
)
{
return
;
}
let
data
:
any
;
try
{
data
=
JSON
.
parse
(
raw
);
}
catch
(
e
)
{
return
;
}
this
.
followCursor
=
data
.
followCursor
;
this
.
sortBy
=
data
.
sortBy
;
}
}
export
class
OutlinePanel
extends
ViewsViewletPanel
{
private
_disposables
=
new
Array
<
IDisposable
>
();
private
_editorDisposables
=
new
Array
<
IDisposable
>
();
private
_outlineViewState
=
new
OutlineState
();
private
_requestOracle
:
RequestOracle
;
private
_domNode
:
HTMLElement
;
private
_message
:
HTMLDivElement
;
...
...
@@ -116,18 +169,18 @@ export class OutlinePanel extends ViewsViewletPanel {
private
_treeComparator
:
OutlineItemComparator
;
private
_treeStates
=
new
LRUCache
<
string
,
OutlineTreeState
>
(
10
);
// todo@joh have memento object
private
_followCursor
=
false
;
constructor
(
options
:
IViewOptions
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
IThemeService
private
readonly
_themeService
:
IThemeService
,
@
IStorageService
private
readonly
_storageService
:
IStorageService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
super
(
options
,
keybindingService
,
contextMenuService
,
configurationService
);
this
.
_outlineViewState
.
restore
(
this
.
_storageService
);
}
dispose
():
void
{
...
...
@@ -178,11 +231,13 @@ export class OutlinePanel extends ViewsViewletPanel {
};
const
dataSource
=
new
OutlineDataSource
();
const
renderer
=
new
OutlineRenderer
();
this
.
_treeComparator
=
new
OutlineItemComparator
();
this
.
_treeComparator
=
new
OutlineItemComparator
(
this
.
_outlineViewState
.
sortBy
);
this
.
_treeFilter
=
new
OutlineItemFilter
();
this
.
_tree
=
this
.
_instantiationService
.
createInstance
(
WorkbenchTree
,
treeContainer
,
{
controller
,
dataSource
,
renderer
,
sorter
:
this
.
_treeComparator
,
filter
:
this
.
_treeFilter
},
{});
this
.
_disposables
.
push
(
this
.
_tree
,
this
.
_input
);
this
.
_disposables
.
push
(
this
.
_outlineViewState
.
onDidChange
(
this
.
_onDidChangeUserState
,
this
));
}
protected
layoutBody
(
height
:
number
):
void
{
...
...
@@ -210,12 +265,12 @@ export class OutlinePanel extends ViewsViewletPanel {
getSecondaryActions
():
IAction
[]
{
let
group
=
new
RadioGroup
([
new
SimpleToggleAction
(
localize
(
'
sortByPosition
'
,
"
Sort By: Position
"
),
t
rue
,
_
=>
this
.
_onSortTypeChanged
(
OutlineItemCompareType
.
ByPosition
)
),
new
SimpleToggleAction
(
localize
(
'
sortByName
'
,
"
Sort By: Name
"
),
false
,
_
=>
this
.
_onSortTypeChanged
(
OutlineItemCompareType
.
ByName
)
),
new
SimpleToggleAction
(
localize
(
'
sortByKind
'
,
"
Sort By: Type
"
),
false
,
_
=>
this
.
_onSortTypeChanged
(
OutlineItemCompareType
.
ByKind
)
),
new
SimpleToggleAction
(
localize
(
'
sortByPosition
'
,
"
Sort By: Position
"
),
t
his
.
_outlineViewState
.
sortBy
===
OutlineItemCompareType
.
ByPosition
,
_
=>
this
.
_outlineViewState
.
sortBy
=
OutlineItemCompareType
.
ByPosition
),
new
SimpleToggleAction
(
localize
(
'
sortByName
'
,
"
Sort By: Name
"
),
this
.
_outlineViewState
.
sortBy
===
OutlineItemCompareType
.
ByName
,
_
=>
this
.
_outlineViewState
.
sortBy
=
OutlineItemCompareType
.
ByName
),
new
SimpleToggleAction
(
localize
(
'
sortByKind
'
,
"
Sort By: Type
"
),
this
.
_outlineViewState
.
sortBy
===
OutlineItemCompareType
.
ByKind
,
_
=>
this
.
_outlineViewState
.
sortBy
=
OutlineItemCompareType
.
ByKind
),
]);
let
result
=
[
new
SimpleToggleAction
(
localize
(
'
live
'
,
"
Follow Cursor
"
),
false
,
action
=>
this
.
_
followCursor
=
action
.
checked
),
new
SimpleToggleAction
(
localize
(
'
live
'
,
"
Follow Cursor
"
),
this
.
_outlineViewState
.
followCursor
,
action
=>
this
.
_outlineViewState
.
followCursor
=
action
.
checked
),
new
Separator
(),
...
group
.
actions
,
];
...
...
@@ -225,9 +280,13 @@ export class OutlinePanel extends ViewsViewletPanel {
return
result
;
}
private
_onSortTypeChanged
(
type
:
OutlineItemCompareType
)
{
if
(
this
.
_treeComparator
.
type
!==
type
)
{
this
.
_treeComparator
.
type
=
type
;
private
_onDidChangeUserState
(
e
:
{
followCursor
?:
boolean
,
sortBy
?:
boolean
})
{
this
.
_outlineViewState
.
persist
(
this
.
_storageService
);
if
(
e
.
followCursor
)
{
// todo@joh update immediately
}
if
(
e
.
sortBy
)
{
this
.
_treeComparator
.
type
=
this
.
_outlineViewState
.
sortBy
;
this
.
_tree
.
refresh
(
undefined
,
true
);
}
}
...
...
@@ -320,7 +379,7 @@ export class OutlinePanel extends ViewsViewletPanel {
}
private
async
_revealEditorSelection
(
group
:
OutlineItemGroup
,
selection
:
Selection
):
TPromise
<
void
>
{
if
(
!
this
.
_followCursor
)
{
if
(
!
this
.
_
outlineViewState
.
followCursor
)
{
return
;
}
let
item
=
group
.
getItemEnclosingPosition
({
...
...
src/vs/workbench/parts/outline/electron-browser/outlineTree.ts
浏览文件 @
7fda0363
...
...
@@ -26,7 +26,9 @@ export enum OutlineItemCompareType {
export
class
OutlineItemComparator
implements
ISorter
{
type
:
OutlineItemCompareType
=
OutlineItemCompareType
.
ByPosition
;
constructor
(
public
type
:
OutlineItemCompareType
=
OutlineItemCompareType
.
ByPosition
)
{
}
compare
(
tree
:
ITree
,
a
:
OutlineItem
,
b
:
OutlineItem
):
number
{
switch
(
this
.
type
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录