Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a5745f50
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,发现更多精彩内容 >>
提交
a5745f50
编写于
9月 30, 2019
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[folding] Support single shortcut for toggling fold/unfold. Fixes #18549
上级
3f3a9e30
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
46 addition
and
1 deletion
+46
-1
src/vs/editor/contrib/folding/folding.ts
src/vs/editor/contrib/folding/folding.ts
+26
-1
src/vs/editor/contrib/folding/foldingModel.ts
src/vs/editor/contrib/folding/foldingModel.ts
+20
-0
未找到文件。
src/vs/editor/contrib/folding/folding.ts
浏览文件 @
a5745f50
...
@@ -14,7 +14,7 @@ import { ScrollType, IEditorContribution } from 'vs/editor/common/editorCommon';
...
@@ -14,7 +14,7 @@ import { ScrollType, IEditorContribution } from 'vs/editor/common/editorCommon';
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
registerEditorAction
,
registerEditorContribution
,
ServicesAccessor
,
EditorAction
,
registerInstantiatedEditorAction
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
registerEditorAction
,
registerEditorContribution
,
ServicesAccessor
,
EditorAction
,
registerInstantiatedEditorAction
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
,
MouseTargetType
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
,
MouseTargetType
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
FoldingModel
,
setCollapseStateAtLevel
,
CollapseMemento
,
setCollapseStateLevelsDown
,
setCollapseStateLevelsUp
,
setCollapseStateForMatchingLines
,
setCollapseStateForType
}
from
'
vs/editor/contrib/folding/foldingModel
'
;
import
{
FoldingModel
,
setCollapseStateAtLevel
,
CollapseMemento
,
setCollapseStateLevelsDown
,
setCollapseStateLevelsUp
,
setCollapseStateForMatchingLines
,
setCollapseStateForType
,
toggleCollapseState
}
from
'
vs/editor/contrib/folding/foldingModel
'
;
import
{
FoldingDecorationProvider
}
from
'
./foldingDecorations
'
;
import
{
FoldingDecorationProvider
}
from
'
./foldingDecorations
'
;
import
{
FoldingRegions
,
FoldingRegion
}
from
'
./foldingRanges
'
;
import
{
FoldingRegions
,
FoldingRegion
}
from
'
./foldingRanges
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
...
@@ -656,6 +656,30 @@ class FoldAction extends FoldingAction<FoldingArguments> {
...
@@ -656,6 +656,30 @@ class FoldAction extends FoldingAction<FoldingArguments> {
}
}
}
}
class
ToggleFoldAction
extends
FoldingAction
<
void
>
{
constructor
()
{
super
({
id
:
'
editor.toggleFold
'
,
label
:
nls
.
localize
(
'
toggleFoldAction.label
'
,
"
Toggle Fold
"
),
alias
:
'
Toggle Fold
'
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
),
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
invoke
(
_foldingController
:
FoldingController
,
foldingModel
:
FoldingModel
,
editor
:
ICodeEditor
):
void
{
let
selectedLines
=
this
.
getSelectedLines
(
editor
);
toggleCollapseState
(
foldingModel
,
1
,
selectedLines
);
}
}
class
FoldRecursivelyAction
extends
FoldingAction
<
void
>
{
class
FoldRecursivelyAction
extends
FoldingAction
<
void
>
{
constructor
()
{
constructor
()
{
...
@@ -842,6 +866,7 @@ registerEditorAction(UnfoldAllAction);
...
@@ -842,6 +866,7 @@ registerEditorAction(UnfoldAllAction);
registerEditorAction
(
FoldAllBlockCommentsAction
);
registerEditorAction
(
FoldAllBlockCommentsAction
);
registerEditorAction
(
FoldAllRegionsAction
);
registerEditorAction
(
FoldAllRegionsAction
);
registerEditorAction
(
UnfoldAllRegionsAction
);
registerEditorAction
(
UnfoldAllRegionsAction
);
registerEditorAction
(
ToggleFoldAction
);
for
(
let
i
=
1
;
i
<=
7
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
7
;
i
++
)
{
registerInstantiatedEditorAction
(
registerInstantiatedEditorAction
(
...
...
src/vs/editor/contrib/folding/foldingModel.ts
浏览文件 @
a5745f50
...
@@ -242,6 +242,26 @@ export class FoldingModel {
...
@@ -242,6 +242,26 @@ export class FoldingModel {
}
}
/**
* Collapse or expand the regions at the given locations
* @param levels The number of levels. Use 1 to only impact the regions at the location, use Number.MAX_VALUE for all levels.
* @param lineNumbers the location of the regions to collapse or expand, or if not set, all regions in the model.
*/
export
function
toggleCollapseState
(
foldingModel
:
FoldingModel
,
levels
:
number
,
lineNumbers
:
number
[])
{
let
toToggle
:
FoldingRegion
[]
=
[];
for
(
let
lineNumber
of
lineNumbers
)
{
let
region
=
foldingModel
.
getRegionAtLine
(
lineNumber
);
if
(
region
)
{
const
doCollapse
=
!
region
.
isCollapsed
;
toToggle
.
push
(
region
);
if
(
levels
>
1
)
{
let
regionsInside
=
foldingModel
.
getRegionsInside
(
region
,
(
r
,
level
:
number
)
=>
r
.
isCollapsed
!==
doCollapse
&&
level
<
levels
);
toToggle
.
push
(...
regionsInside
);
}
}
}
foldingModel
.
toggleCollapseState
(
toToggle
);
}
/**
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录