Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f786c63c
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,发现更多精彩内容 >>
提交
f786c63c
编写于
12月 14, 2021
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Collapse interactive window cells by default
Fix #139153
上级
21434bc2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
57 addition
and
12 deletion
+57
-12
src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
...h/contrib/interactive/browser/interactive.contribution.ts
+5
-1
src/vs/workbench/contrib/interactive/browser/interactiveEditor.ts
...orkbench/contrib/interactive/browser/interactiveEditor.ts
+2
-1
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+2
-1
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
...h/contrib/notebook/browser/viewModel/baseCellViewModel.ts
+8
-0
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
...ch/contrib/notebook/common/model/notebookCellTextModel.ts
+4
-3
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+15
-3
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+11
-0
src/vs/workbench/contrib/notebook/common/notebookOptions.ts
src/vs/workbench/contrib/notebook/common/notebookOptions.ts
+9
-2
src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts
...bench/contrib/notebook/test/browser/testNotebookEditor.ts
+1
-1
未找到文件。
src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
浏览文件 @
f786c63c
...
...
@@ -458,7 +458,11 @@ registerAction2(class extends Action2 {
language
,
source
:
value
,
outputs
:
[],
metadata
:
{}
metadata
:
{},
collapseState
:
{
inputCollapsed
:
false
,
outputCollapsed
:
false
}
}]
}
)
...
...
src/vs/workbench/contrib/interactive/browser/interactiveEditor.ts
浏览文件 @
f786c63c
...
...
@@ -126,7 +126,7 @@ export class InteractiveEditor extends EditorPane {
this
.
#
menuService
=
menuService
;
this
.
#
contextMenuService
=
contextMenuService
;
this
.
#
notebookOptions
=
new
NotebookOptions
(
configurationService
,
{
cellToolbarInteraction
:
'
hover
'
,
globalToolbar
:
true
});
this
.
#
notebookOptions
=
new
NotebookOptions
(
configurationService
,
{
cellToolbarInteraction
:
'
hover
'
,
globalToolbar
:
true
,
defaultCellCollapseConfig
:
{
codeCell
:
{
inputCollapsed
:
true
}}
});
codeEditorService
.
registerDecorationType
(
'
interactive-decoration
'
,
DECORATION_KEY
,
{});
this
.
_register
(
this
.
#
keybindingService
.
onDidUpdateKeybindings
(
this
.
#
updateInputDecoration
,
this
));
...
...
@@ -319,6 +319,7 @@ export class InteractiveEditor extends EditorPane {
this
.
#
notebookWidget
.
value
?.
setParentContextKeyService
(
this
.
#
contextKeyService
);
await
this
.
#
notebookWidget
.
value
!
.
setModel
(
model
.
notebook
,
undefined
);
model
.
notebook
.
setCellCollapseDefault
(
this
.
#
notebookOptions
.
getCellDefaultCollapseConfig
());
this
.
#
notebookWidget
.
value
!
.
setOptions
({
isReadOnly
:
true
});
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
f786c63c
...
...
@@ -14,7 +14,7 @@ import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/con
import
{
OutputRenderer
}
from
'
vs/workbench/contrib/notebook/browser/view/output/outputRenderer
'
;
import
{
CellViewModel
,
IModelDecorationsChangeAccessor
,
INotebookEditorViewState
,
INotebookViewCellsUpdateEvent
,
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
NotebookCellMetadata
,
IOrderedMimeType
,
INotebookRendererInfo
,
ICellOutput
,
INotebookCellStatusBarItem
,
NotebookCellInternalMetadata
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
NotebookCellMetadata
,
IOrderedMimeType
,
INotebookRendererInfo
,
ICellOutput
,
INotebookCellStatusBarItem
,
NotebookCellInternalMetadata
,
NotebookDocumentMetadata
,
NotebookCellCollapseState
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ICellRange
,
cellRangesToIndexes
,
reduceCellRanges
}
from
'
vs/workbench/contrib/notebook/common/notebookRange
'
;
import
{
IWebview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
...
...
@@ -330,6 +330,7 @@ export interface INotebookEditorOptions extends ITextEditorOptions {
readonly
cellSelections
?:
ICellRange
[];
readonly
isReadOnly
?:
boolean
;
readonly
viewState
?:
INotebookEditorViewState
;
readonly
defaultCellCollapseState
?:
NotebookCellCollapseState
;
}
export
type
INotebookEditorContributionCtor
=
IConstructorSignature1
<
INotebookEditor
,
INotebookEditorContribution
>
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
浏览文件 @
f786c63c
...
...
@@ -198,6 +198,14 @@ export abstract class BaseCellViewModel extends Disposable {
this
.
lineNumbers
=
'
inherit
'
;
}
}));
if
(
this
.
model
.
collapseState
?.
inputCollapsed
)
{
this
.
_inputCollapsed
=
true
;
}
if
(
this
.
model
.
collapseState
?.
outputCollapsed
)
{
this
.
_outputCollapsed
=
true
;
}
}
...
...
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
浏览文件 @
f786c63c
...
...
@@ -15,7 +15,7 @@ import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeText
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
NotebookCellOutputTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellOutputTextModel
'
;
import
{
CellInternalMetadataChangedEvent
,
CellKind
,
ICell
,
ICellOutput
,
IOutputDto
,
IOutputItemDto
,
NotebookCellInternalMetadata
,
NotebookCellMetadata
,
NotebookCellOutputsSplice
,
TransientOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellInternalMetadataChangedEvent
,
CellKind
,
ICell
,
ICellOutput
,
IOutputDto
,
IOutputItemDto
,
NotebookCell
CollapseState
,
NotebookCell
InternalMetadata
,
NotebookCellMetadata
,
NotebookCellOutputsSplice
,
TransientOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
export
class
NotebookCellTextModel
extends
Disposable
implements
ICell
{
private
readonly
_onDidChangeOutputs
=
this
.
_register
(
new
Emitter
<
NotebookCellOutputsSplice
>
());
...
...
@@ -192,14 +192,15 @@ export class NotebookCellTextModel extends Disposable implements ICell {
constructor
(
readonly
uri
:
URI
,
public
handle
:
number
,
public
readonly
handle
:
number
,
private
_source
:
string
,
private
_language
:
string
,
private
_mime
:
string
|
undefined
,
public
cellKind
:
CellKind
,
public
readonly
cellKind
:
CellKind
,
outputs
:
IOutputDto
[],
metadata
:
NotebookCellMetadata
|
undefined
,
internalMetadata
:
NotebookCellInternalMetadata
|
undefined
,
public
readonly
collapseState
:
NotebookCellCollapseState
|
undefined
,
public
readonly
transientOptions
:
TransientOptions
,
private
readonly
_modeService
:
IModeService
)
{
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
f786c63c
...
...
@@ -8,7 +8,7 @@ import { Emitter, Event, PauseableEmitter } from 'vs/base/common/event';
import
{
Disposable
,
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
INotebookTextModel
,
NotebookCellOutputsSplice
,
NotebookDocumentMetadata
,
NotebookCellMetadata
,
ICellEditOperation
,
CellEditType
,
CellUri
,
diff
,
NotebookCellsChangeType
,
ICellDto2
,
TransientOptions
,
NotebookTextModelChangedEvent
,
IOutputDto
,
ICellOutput
,
IOutputItemDto
,
ISelectionState
,
NullablePartialNotebookCellMetadata
,
NotebookCellInternalMetadata
,
NullablePartialNotebookCellInternalMetadata
,
NotebookTextModelWillAddRemoveEvent
,
NotebookCellTextModelSplice
,
ICell
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookTextModel
,
NotebookCellOutputsSplice
,
NotebookDocumentMetadata
,
NotebookCellMetadata
,
ICellEditOperation
,
CellEditType
,
CellUri
,
diff
,
NotebookCellsChangeType
,
ICellDto2
,
TransientOptions
,
NotebookTextModelChangedEvent
,
IOutputDto
,
ICellOutput
,
IOutputItemDto
,
ISelectionState
,
NullablePartialNotebookCellMetadata
,
NotebookCellInternalMetadata
,
NullablePartialNotebookCellInternalMetadata
,
NotebookTextModelWillAddRemoveEvent
,
NotebookCellTextModelSplice
,
ICell
,
NotebookCellCollapseState
,
NotebookCellDefaultCollapseConfig
,
CellKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IUndoRedoService
,
UndoRedoElementType
,
IUndoRedoElement
,
IResourceUndoRedoElement
,
UndoRedoGroup
,
IWorkspaceUndoRedoElement
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
MoveCellEdit
,
SpliceCellsEdit
,
CellMetadataEdit
}
from
'
vs/workbench/contrib/notebook/common/model/cellEdit
'
;
import
{
ISequence
,
LcsDiff
}
from
'
vs/base/common/diff/diff
'
;
...
...
@@ -168,6 +168,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
private
_cellhandlePool
:
number
=
0
;
private
readonly
_cellListeners
:
Map
<
number
,
IDisposable
>
=
new
Map
();
private
_cells
:
NotebookCellTextModel
[]
=
[];
private
_defaultCollapseConfig
:
NotebookCellDefaultCollapseConfig
|
undefined
;
metadata
:
NotebookDocumentMetadata
=
{};
transientOptions
:
TransientOptions
=
{
transientCellMetadata
:
{},
transientDocumentMetadata
:
{},
transientOutputs
:
false
};
...
...
@@ -269,6 +270,10 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
);
}
setCellCollapseDefault
(
collapseConfig
:
NotebookCellDefaultCollapseConfig
|
undefined
)
{
this
.
_defaultCollapseConfig
=
collapseConfig
;
}
_initialize
(
cells
:
ICellDto2
[],
triggerDirty
?:
boolean
)
{
this
.
_cells
=
[];
this
.
_versionId
=
0
;
...
...
@@ -277,7 +282,8 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
const
mainCells
=
cells
.
map
(
cell
=>
{
const
cellHandle
=
this
.
_cellhandlePool
++
;
const
cellUri
=
CellUri
.
generate
(
this
.
uri
,
cellHandle
);
return
new
NotebookCellTextModel
(
cellUri
,
cellHandle
,
cell
.
source
,
cell
.
language
,
cell
.
mime
,
cell
.
cellKind
,
cell
.
outputs
,
cell
.
metadata
,
cell
.
internalMetadata
,
this
.
transientOptions
,
this
.
_modeService
);
const
collapseState
=
this
.
_getDefaultCollapseState
(
cell
);
return
new
NotebookCellTextModel
(
cellUri
,
cellHandle
,
cell
.
source
,
cell
.
language
,
cell
.
mime
,
cell
.
cellKind
,
cell
.
outputs
,
cell
.
metadata
,
cell
.
internalMetadata
,
collapseState
,
this
.
transientOptions
,
this
.
_modeService
);
});
for
(
let
i
=
0
;
i
<
mainCells
.
length
;
i
++
)
{
...
...
@@ -575,6 +581,11 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
return
mergedEdits
;
}
private
_getDefaultCollapseState
(
cellDto
:
ICellDto2
):
NotebookCellCollapseState
|
undefined
{
const
defaultConfig
=
cellDto
.
cellKind
===
CellKind
.
Code
?
this
.
_defaultCollapseConfig
?.
codeCell
:
this
.
_defaultCollapseConfig
?.
markupCell
;
return
cellDto
.
collapseState
??
(
defaultConfig
??
undefined
);
}
private
_replaceCells
(
index
:
number
,
count
:
number
,
cellDtos
:
ICellDto2
[],
synchronous
:
boolean
,
computeUndoRedo
:
boolean
):
void
{
if
(
count
===
0
&&
cellDtos
.
length
===
0
)
{
...
...
@@ -598,9 +609,10 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
const
cells
=
cellDtos
.
map
(
cellDto
=>
{
const
cellHandle
=
this
.
_cellhandlePool
++
;
const
cellUri
=
CellUri
.
generate
(
this
.
uri
,
cellHandle
);
const
collapseState
=
this
.
_getDefaultCollapseState
(
cellDto
);
const
cell
=
new
NotebookCellTextModel
(
cellUri
,
cellHandle
,
cellDto
.
source
,
cellDto
.
language
,
cellDto
.
mime
,
cellDto
.
cellKind
,
cellDto
.
outputs
||
[],
cellDto
.
metadata
,
cellDto
.
internalMetadata
,
this
.
transientOptions
,
cellDto
.
source
,
cellDto
.
language
,
cellDto
.
mime
,
cellDto
.
cellKind
,
cellDto
.
outputs
||
[],
cellDto
.
metadata
,
cellDto
.
internalMetadata
,
collapseState
,
this
.
transientOptions
,
this
.
_modeService
);
const
textModel
=
this
.
_modelService
.
getModel
(
cellUri
);
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
f786c63c
...
...
@@ -109,6 +109,16 @@ export interface NotebookCellInternalMetadata {
didPause
?:
boolean
;
}
export
interface
NotebookCellCollapseState
{
inputCollapsed
?:
boolean
;
outputCollapsed
?:
boolean
;
}
export
interface
NotebookCellDefaultCollapseConfig
{
codeCell
?:
NotebookCellCollapseState
;
markupCell
?:
NotebookCellCollapseState
;
}
export
type
TransientCellMetadata
=
{
[
K
in
keyof
NotebookCellMetadata
]?:
boolean
};
export
type
TransientDocumentMetadata
=
{
[
K
in
keyof
NotebookDocumentMetadata
]?:
boolean
};
...
...
@@ -386,6 +396,7 @@ export interface ICellDto2 {
outputs
:
IOutputDto
[];
metadata
?:
NotebookCellMetadata
;
internalMetadata
?:
NotebookCellInternalMetadata
;
collapseState
?:
NotebookCellCollapseState
;
}
export
interface
ICellReplaceEdit
{
...
...
src/vs/workbench/contrib/notebook/common/notebookOptions.ts
浏览文件 @
f786c63c
...
...
@@ -6,7 +6,7 @@
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IConfigurationChangeEvent
,
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
NotebookCellInternalMetadata
,
NotebookSetting
,
ShowCellStatusBarType
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookCell
DefaultCollapseConfig
,
NotebookCell
InternalMetadata
,
NotebookSetting
,
ShowCellStatusBarType
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
const
SCROLLABLE_ELEMENT_PADDING_TOP
=
18
;
...
...
@@ -106,10 +106,11 @@ const compactConfigConstants = Object.freeze({
export
class
NotebookOptions
extends
Disposable
{
private
_layoutConfiguration
:
NotebookLayoutConfiguration
;
private
_cellDefaultCollapseConfig
:
NotebookCellDefaultCollapseConfig
|
undefined
;
protected
readonly
_onDidChangeOptions
=
this
.
_register
(
new
Emitter
<
NotebookOptionsChangeEvent
>
());
readonly
onDidChangeOptions
=
this
.
_onDidChangeOptions
.
event
;
constructor
(
private
readonly
configurationService
:
IConfigurationService
,
private
readonly
overrides
?:
{
cellToolbarInteraction
:
string
,
globalToolbar
:
boolean
})
{
constructor
(
private
readonly
configurationService
:
IConfigurationService
,
private
readonly
overrides
?:
{
cellToolbarInteraction
:
string
,
globalToolbar
:
boolean
,
defaultCellCollapseConfig
?:
NotebookCellDefaultCollapseConfig
})
{
super
();
const
showCellStatusBar
=
this
.
configurationService
.
getValue
<
ShowCellStatusBarType
>
(
NotebookSetting
.
showCellStatusBar
);
const
globalToolbar
=
overrides
?.
globalToolbar
??
this
.
configurationService
.
getValue
<
boolean
|
undefined
>
(
NotebookSetting
.
globalToolbar
)
??
true
;
...
...
@@ -170,6 +171,8 @@ export class NotebookOptions extends Disposable {
this
.
_layoutConfiguration
=
configuration
;
this
.
_onDidChangeOptions
.
fire
({
editorTopPadding
:
true
});
}));
this
.
_cellDefaultCollapseConfig
=
overrides
?.
defaultCellCollapseConfig
;
}
private
_updateConfiguration
(
e
:
IConfigurationChangeEvent
)
{
...
...
@@ -312,6 +315,10 @@ export class NotebookOptions extends Disposable {
return
this
.
configurationService
.
getValue
<
'
border
'
|
'
gutter
'
>
(
NotebookSetting
.
focusIndicator
)
??
'
gutter
'
;
}
getCellDefaultCollapseConfig
():
NotebookCellDefaultCollapseConfig
|
undefined
{
return
this
.
_cellDefaultCollapseConfig
;
}
getLayoutConfiguration
():
NotebookLayoutConfiguration
{
return
this
.
_layoutConfiguration
;
}
...
...
src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts
浏览文件 @
f786c63c
...
...
@@ -65,7 +65,7 @@ export class TestCell extends NotebookCellTextModel {
outputs
:
IOutputDto
[],
modeService
:
IModeService
,
)
{
super
(
CellUri
.
generate
(
URI
.
parse
(
'
test:///fake/notebook
'
),
handle
),
handle
,
source
,
language
,
Mimes
.
text
,
cellKind
,
outputs
,
undefined
,
undefined
,
{
transientCellMetadata
:
{},
transientDocumentMetadata
:
{},
transientOutputs
:
false
},
modeService
);
super
(
CellUri
.
generate
(
URI
.
parse
(
'
test:///fake/notebook
'
),
handle
),
handle
,
source
,
language
,
Mimes
.
text
,
cellKind
,
outputs
,
undefined
,
undefined
,
undefined
,
{
transientCellMetadata
:
{},
transientDocumentMetadata
:
{},
transientOutputs
:
false
},
modeService
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录