Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
759ac9fe
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
未验证
提交
759ac9fe
编写于
7月 10, 2019
作者:
I
Isidor Nikolic
提交者:
GitHub
7月 10, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #76979 from microsoft/isidorn/foldingContext
folding: introduce foldingEnabled context
上级
57fce25a
2bcc197d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
12 deletion
+20
-12
src/vs/editor/contrib/folding/folding.ts
src/vs/editor/contrib/folding/folding.ts
+20
-12
未找到文件。
src/vs/editor/contrib/folding/folding.ts
浏览文件 @
759ac9fe
...
...
@@ -31,7 +31,9 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import
{
InitializingRangeProvider
,
ID_INIT_PROVIDER
}
from
'
vs/editor/contrib/folding/intializingRangeProvider
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
RawContextKey
,
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
const
CONTEXT_FOLDING_ENABLED
=
new
RawContextKey
<
boolean
>
(
'
foldingEnabled
'
,
false
);
export
const
ID
=
'
editor.contrib.folding
'
;
export
interface
RangeProvider
{
...
...
@@ -73,12 +75,15 @@ export class FoldingController extends Disposable implements IEditorContribution
private
foldingModelPromise
:
Promise
<
FoldingModel
|
null
>
|
null
;
private
updateScheduler
:
Delayer
<
FoldingModel
|
null
>
|
null
;
private
foldingEnabled
:
IContextKey
<
boolean
>
;
private
cursorChangedScheduler
:
RunOnceScheduler
|
null
;
private
readonly
localToDispose
=
this
.
_register
(
new
DisposableStore
());
constructor
(
editor
:
ICodeEditor
)
{
constructor
(
editor
:
ICodeEditor
,
@
IContextKeyService
private
readonly
contextKeyService
:
IContextKeyService
)
{
super
();
this
.
editor
=
editor
;
this
.
_isEnabled
=
this
.
editor
.
getConfiguration
().
contribInfo
.
folding
;
...
...
@@ -88,6 +93,8 @@ export class FoldingController extends Disposable implements IEditorContribution
this
.
foldingDecorationProvider
=
new
FoldingDecorationProvider
(
editor
);
this
.
foldingDecorationProvider
.
autoHideFoldingControls
=
this
.
_autoHideFoldingControls
;
this
.
foldingEnabled
=
CONTEXT_FOLDING_ENABLED
.
bindTo
(
this
.
contextKeyService
);
this
.
foldingEnabled
.
set
(
this
.
_isEnabled
);
this
.
_register
(
this
.
editor
.
onDidChangeModel
(()
=>
this
.
onModelChanged
()));
...
...
@@ -95,6 +102,7 @@ export class FoldingController extends Disposable implements IEditorContribution
if
(
e
.
contribInfo
)
{
let
oldIsEnabled
=
this
.
_isEnabled
;
this
.
_isEnabled
=
this
.
editor
.
getConfiguration
().
contribInfo
.
folding
;
this
.
foldingEnabled
.
set
(
this
.
_isEnabled
);
if
(
oldIsEnabled
!==
this
.
_isEnabled
)
{
this
.
onModelChanged
();
}
...
...
@@ -496,7 +504,7 @@ class UnfoldAction extends FoldingAction<FoldingArguments> {
id
:
'
editor.unfold
'
,
label
:
nls
.
localize
(
'
unfoldAction.label
'
,
"
Unfold
"
),
alias
:
'
Unfold
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
US_CLOSE_SQUARE_BRACKET
,
...
...
@@ -560,7 +568,7 @@ class UnFoldRecursivelyAction extends FoldingAction<void> {
id
:
'
editor.unfoldRecursively
'
,
label
:
nls
.
localize
(
'
unFoldRecursivelyAction.label
'
,
"
Unfold Recursively
"
),
alias
:
'
Unfold Recursively
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
US_CLOSE_SQUARE_BRACKET
),
...
...
@@ -581,7 +589,7 @@ class FoldAction extends FoldingAction<FoldingArguments> {
id
:
'
editor.fold
'
,
label
:
nls
.
localize
(
'
foldAction.label
'
,
"
Fold
"
),
alias
:
'
Fold
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
US_OPEN_SQUARE_BRACKET
,
...
...
@@ -645,7 +653,7 @@ class FoldRecursivelyAction extends FoldingAction<void> {
id
:
'
editor.foldRecursively
'
,
label
:
nls
.
localize
(
'
foldRecursivelyAction.label
'
,
"
Fold Recursively
"
),
alias
:
'
Fold Recursively
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
US_OPEN_SQUARE_BRACKET
),
...
...
@@ -667,7 +675,7 @@ class FoldAllBlockCommentsAction extends FoldingAction<void> {
id
:
'
editor.foldAllBlockComments
'
,
label
:
nls
.
localize
(
'
foldAllBlockComments.label
'
,
"
Fold All Block Comments
"
),
alias
:
'
Fold All Block Comments
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
US_SLASH
),
...
...
@@ -700,7 +708,7 @@ class FoldAllRegionsAction extends FoldingAction<void> {
id
:
'
editor.foldAllMarkerRegions
'
,
label
:
nls
.
localize
(
'
foldAllMarkerRegions.label
'
,
"
Fold All Regions
"
),
alias
:
'
Fold All Regions
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_8
),
...
...
@@ -733,7 +741,7 @@ class UnfoldAllRegionsAction extends FoldingAction<void> {
id
:
'
editor.unfoldAllMarkerRegions
'
,
label
:
nls
.
localize
(
'
unfoldAllMarkerRegions.label
'
,
"
Unfold All Regions
"
),
alias
:
'
Unfold All Regions
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_9
),
...
...
@@ -766,7 +774,7 @@ class FoldAllAction extends FoldingAction<void> {
id
:
'
editor.foldAll
'
,
label
:
nls
.
localize
(
'
foldAllAction.label
'
,
"
Fold All
"
),
alias
:
'
Fold All
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_0
),
...
...
@@ -787,7 +795,7 @@ class UnfoldAllAction extends FoldingAction<void> {
id
:
'
editor.unfoldAll
'
,
label
:
nls
.
localize
(
'
unfoldAllAction.label
'
,
"
Unfold All
"
),
alias
:
'
Unfold All
'
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_J
),
...
...
@@ -831,7 +839,7 @@ for (let i = 1; i <= 7; i++) {
id
:
FoldLevelAction
.
ID
(
i
),
label
:
nls
.
localize
(
'
foldLevelAction.label
'
,
"
Fold Level {0}
"
,
i
),
alias
:
`Fold Level
${
i
}
`
,
precondition
:
undefined
,
precondition
:
CONTEXT_FOLDING_ENABLED
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
(
KeyCode
.
KEY_0
+
i
)),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录