Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f5026604
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,发现更多精彩内容 >>
提交
f5026604
编写于
4月 06, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove unused outline navigation
上级
652216af
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
0 addition
and
204 deletion
+0
-204
src/vs/workbench/contrib/outline/browser/outline.contribution.ts
...workbench/contrib/outline/browser/outline.contribution.ts
+0
-2
src/vs/workbench/contrib/outline/browser/outlineNavigation.ts
...vs/workbench/contrib/outline/browser/outlineNavigation.ts
+0
-202
未找到文件。
src/vs/workbench/contrib/outline/browser/outline.contribution.ts
浏览文件 @
f5026604
...
...
@@ -12,8 +12,6 @@ import { OutlineConfigKeys, OutlineViewId } from 'vs/editor/contrib/documentSymb
import
{
VIEW_CONTAINER
}
from
'
vs/workbench/contrib/files/browser/explorerViewlet
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
// import './outlineNavigation';
export
const
PANEL_ID
=
'
panel.view.outline
'
;
const
_outlineDesc
=
<
IViewDescriptor
>
{
...
...
src/vs/workbench/contrib/outline/browser/outlineNavigation.ts
已删除
100644 → 0
浏览文件 @
652216af
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IPosition
,
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
OutlineElement
,
OutlineModel
,
TreeElement
}
from
'
vs/editor/contrib/documentSymbols/outlineModel
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IEditorContribution
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
EditorStateCancellationTokenSource
,
CodeEditorStateFlag
}
from
'
vs/editor/browser/core/editorState
'
;
import
{
EditorAction
,
registerEditorAction
,
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
forEach
}
from
'
vs/base/common/collections
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
OutlineFilter
}
from
'
vs/editor/contrib/documentSymbols/outlineTree
'
;
import
{
binarySearch
}
from
'
vs/base/common/arrays
'
;
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/textResourceConfigurationService
'
;
class
FlatOutline
{
readonly
elements
:
OutlineElement
[]
=
[];
readonly
_elementPositions
:
IPosition
[];
constructor
(
model
:
OutlineModel
,
filter
:
OutlineFilter
)
{
const
walk
=
(
element
:
TreeElement
)
=>
{
if
(
element
instanceof
OutlineElement
&&
!
filter
.
filter
(
element
))
{
return
;
}
if
(
element
instanceof
OutlineElement
)
{
this
.
elements
.
push
(
element
);
}
forEach
(
element
.
children
,
entry
=>
walk
(
entry
.
value
));
};
walk
(
model
);
this
.
elements
.
sort
(
FlatOutline
.
_compare
);
this
.
_elementPositions
=
this
.
elements
.
map
(
element
=>
({
lineNumber
:
element
.
symbol
.
range
.
startLineNumber
,
column
:
element
.
symbol
.
range
.
startColumn
}));
}
private
static
_compare
(
a
:
TreeElement
,
b
:
TreeElement
):
number
{
return
(
a
instanceof
OutlineElement
&&
b
instanceof
OutlineElement
)
?
Range
.
compareRangesUsingStarts
(
a
.
symbol
.
range
,
b
.
symbol
.
range
)
:
0
;
}
find
(
position
:
IPosition
,
preferAfter
:
boolean
):
number
{
const
idx
=
binarySearch
(
this
.
_elementPositions
,
position
,
Position
.
compare
);
if
(
idx
>=
0
)
{
return
idx
;
}
else
if
(
preferAfter
)
{
return
~
idx
;
}
else
{
return
~
idx
-
1
;
}
}
}
export
class
OutlineNavigation
implements
IEditorContribution
{
public
static
readonly
ID
=
'
editor.contrib.OutlineNavigation
'
;
public
static
get
(
editor
:
ICodeEditor
):
OutlineNavigation
{
return
editor
.
getContribution
<
OutlineNavigation
>
(
OutlineNavigation
.
ID
);
}
private
readonly
_editor
:
ICodeEditor
;
private
_cts
?:
CancellationTokenSource
;
constructor
(
editor
:
ICodeEditor
,
@
ITextResourceConfigurationService
private
readonly
_textResourceConfigService
:
ITextResourceConfigurationService
,
)
{
this
.
_editor
=
editor
;
}
dispose
():
void
{
if
(
this
.
_cts
)
{
this
.
_cts
.
dispose
(
true
);
}
}
async
goto
(
up
:
boolean
)
{
if
(
this
.
_cts
)
{
this
.
_cts
.
dispose
(
true
);
}
if
(
!
this
.
_editor
.
hasModel
())
{
return
;
}
const
textModel
=
this
.
_editor
.
getModel
();
const
position
=
this
.
_editor
.
getPosition
();
this
.
_cts
=
new
EditorStateCancellationTokenSource
(
this
.
_editor
,
CodeEditorStateFlag
.
Position
|
CodeEditorStateFlag
.
Value
|
CodeEditorStateFlag
.
Scroll
);
const
filter
=
new
OutlineFilter
(
'
outline
'
,
this
.
_textResourceConfigService
);
const
outlineModel
=
await
OutlineModel
.
create
(
textModel
,
this
.
_cts
.
token
);
if
(
this
.
_cts
.
token
.
isCancellationRequested
)
{
return
;
}
const
symbols
=
new
FlatOutline
(
outlineModel
,
filter
);
const
idx
=
symbols
.
find
(
position
,
!
up
);
const
element
=
symbols
.
elements
[
idx
];
if
(
element
)
{
if
(
Range
.
containsPosition
(
element
.
symbol
.
selectionRange
,
position
))
{
// at the "name" of a symbol -> move
const
nextElement
=
symbols
.
elements
[
idx
+
(
up
?
-
1
:
+
1
)];
this
.
_revealElement
(
nextElement
);
}
else
{
// enclosing, lastBefore, or firstAfter element
this
.
_revealElement
(
element
);
}
}
}
private
_revealElement
(
element
:
OutlineElement
|
undefined
):
void
{
if
(
!
element
)
{
return
;
}
const
pos
=
Range
.
lift
(
element
.
symbol
.
selectionRange
).
getStartPosition
();
this
.
_editor
.
setPosition
(
pos
);
this
.
_editor
.
revealPosition
(
pos
,
ScrollType
.
Smooth
);
const
modelNow
=
this
.
_editor
.
getModel
();
const
ids
=
this
.
_editor
.
deltaDecorations
([],
[{
range
:
element
.
symbol
.
selectionRange
,
options
:
{
className
:
'
symbolHighlight
'
,
}
}]);
setTimeout
(()
=>
{
if
(
modelNow
===
this
.
_editor
.
getModel
())
{
this
.
_editor
.
deltaDecorations
(
ids
,
[]);
}
},
350
);
}
}
registerEditorContribution
(
OutlineNavigation
.
ID
,
OutlineNavigation
);
registerEditorAction
(
class
extends
EditorAction
{
constructor
()
{
super
({
id
:
'
editor.action.gotoNextSymbol
'
,
label
:
localize
(
'
label.next
'
,
"
Go to Next Symbol
"
),
alias
:
'
Go to Next Symbol
'
,
precondition
:
EditorContextKeys
.
hasDocumentSymbolProvider
,
kbOpts
:
{
weight
:
KeybindingWeight
.
EditorContrib
,
kbExpr
:
EditorContextKeys
.
focus
,
primary
:
undefined
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyMod
.
Shift
|
KeyCode
.
DownArrow
,
},
}
});
}
run
(
_accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
|
Promise
<
void
>
{
OutlineNavigation
.
get
(
editor
).
goto
(
false
);
}
});
registerEditorAction
(
class
extends
EditorAction
{
constructor
()
{
super
({
id
:
'
editor.action.gotoPrevSymbol
'
,
label
:
localize
(
'
label.prev
'
,
"
Go to Previous Symbol
"
),
alias
:
'
Go to Previous Symbol
'
,
precondition
:
EditorContextKeys
.
hasDocumentSymbolProvider
,
kbOpts
:
{
weight
:
KeybindingWeight
.
EditorContrib
,
kbExpr
:
EditorContextKeys
.
focus
,
primary
:
undefined
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyMod
.
Shift
|
KeyCode
.
UpArrow
,
},
}
});
}
run
(
_accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
|
Promise
<
void
>
{
OutlineNavigation
.
get
(
editor
).
goto
(
true
);
}
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录