Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eb05e94d
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,发现更多精彩内容 >>
提交
eb05e94d
编写于
8月 01, 2020
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Send cell metadata changes to EH, add onDidChangeCellMetadata event
上级
8d51d4a4
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
89 addition
and
66 deletion
+89
-66
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+6
-0
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+4
-0
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+28
-7
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
...workbench/contrib/notebook/browser/contrib/coreActions.ts
+5
-5
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+0
-7
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
...ntrib/notebook/browser/view/renderers/backLayerWebView.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys.ts
...ontrib/notebook/browser/view/renderers/cellContextKeys.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+5
-5
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
...bench/contrib/notebook/browser/view/renderers/codeCell.ts
+4
-4
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
...h/contrib/notebook/browser/view/renderers/markdownCell.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
...h/contrib/notebook/browser/viewModel/baseCellViewModel.ts
+1
-23
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
...h/contrib/notebook/browser/viewModel/codeCellViewModel.ts
+4
-4
src/vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel.ts
...ntrib/notebook/browser/viewModel/markdownCellViewModel.ts
+2
-2
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+13
-0
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+10
-2
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
eb05e94d
...
...
@@ -1599,6 +1599,11 @@ declare module 'vscode' {
readonly
language
:
string
;
}
export
interface
NotebookCellMetadataChangeEvent
{
readonly
document
:
NotebookDocument
;
readonly
cell
:
NotebookCell
;
}
export
interface
NotebookCellData
{
readonly
cellKind
:
CellKind
;
readonly
source
:
string
;
...
...
@@ -1789,6 +1794,7 @@ declare module 'vscode' {
export
const
onDidChangeNotebookCells
:
Event
<
NotebookCellsChangeEvent
>
;
export
const
onDidChangeCellOutputs
:
Event
<
NotebookCellOutputsChangeEvent
>
;
export
const
onDidChangeCellLanguage
:
Event
<
NotebookCellLanguageChangeEvent
>
;
export
const
onDidChangeCellMetadata
:
Event
<
NotebookCellMetadataChangeEvent
>
;
/**
* Create a document that is the concatenation of all notebook cells. By default all code-cells are included
* but a selector can be provided to narrow to down the set of cells.
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
eb05e94d
...
...
@@ -973,6 +973,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
onDidChangeCellLanguage
(
listener
,
thisArgs
,
disposables
);
},
onDidChangeCellMetadata
(
listener
,
thisArgs
?,
disposables
?)
{
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
onDidChangeCellMetadata
(
listener
,
thisArgs
,
disposables
);
},
createConcatTextDocument
(
notebook
,
selector
)
{
checkProposedApiEnabled
(
extension
);
return
new
ExtHostNotebookConcatDocument
(
extHostNotebook
,
extHostDocuments
,
notebook
,
selector
);
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
eb05e94d
...
...
@@ -14,7 +14,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
import
{
CellKind
,
ExtHostNotebookShape
,
IMainContext
,
MainContext
,
MainThreadNotebookShape
,
NotebookCellOutputsSplice
,
MainThreadDocumentsShape
,
INotebookEditorPropertiesChangeData
,
INotebookDocumentsAndEditorsDelta
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/common/extHostCommands
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
CellEditType
,
diff
,
ICellEditOperation
,
ICellInsertEdit
,
INotebookDisplayOrder
,
INotebookEditData
,
NotebookCellsChangedEvent
,
NotebookCellsSplice2
,
ICellDeleteEdit
,
notebookDocumentMetadataDefaults
,
NotebookCellsChangeType
,
NotebookDataDto
,
IOutputRenderRequest
,
IOutputRenderResponse
,
IOutputRenderResponseOutputInfo
,
IOutputRenderResponseCellInfo
,
IRawOutput
,
CellOutputKind
,
IProcessedOutput
,
INotebookKernelInfoDto2
,
IMainCellDto
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellEditType
,
diff
,
ICellEditOperation
,
ICellInsertEdit
,
INotebookDisplayOrder
,
INotebookEditData
,
NotebookCellsChangedEvent
,
NotebookCellsSplice2
,
ICellDeleteEdit
,
notebookDocumentMetadataDefaults
,
NotebookCellsChangeType
,
NotebookDataDto
,
IOutputRenderRequest
,
IOutputRenderResponse
,
IOutputRenderResponseOutputInfo
,
IOutputRenderResponseCellInfo
,
IRawOutput
,
CellOutputKind
,
IProcessedOutput
,
INotebookKernelInfoDto2
,
IMainCellDto
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
*
as
extHostTypes
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
CancellationToken
,
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
ExtHostDocumentData
}
from
'
vs/workbench/api/common/extHostDocumentData
'
;
...
...
@@ -52,6 +52,7 @@ interface INotebookEventEmitter {
emitModelChange
(
events
:
vscode
.
NotebookCellsChangeEvent
):
void
;
emitCellOutputsChange
(
event
:
vscode
.
NotebookCellOutputsChangeEvent
):
void
;
emitCellLanguageChange
(
event
:
vscode
.
NotebookCellLanguageChangeEvent
):
void
;
emitCellMetadataChange
(
event
:
vscode
.
NotebookCellMetadataChangeEvent
):
void
;
}
const
addIdToOutput
=
(
output
:
IRawOutput
,
id
=
UUID
.
generateUuid
()):
IProcessedOutput
=>
output
.
outputKind
===
CellOutputKind
.
Rich
...
...
@@ -172,6 +173,11 @@ export class ExtHostCell extends Disposable implements vscode.NotebookCell {
}
set
metadata
(
newMetadata
:
vscode
.
NotebookCellMetadata
)
{
this
.
setMetadata
(
newMetadata
);
this
.
_updateMetadata
();
}
setMetadata
(
newMetadata
:
vscode
.
NotebookCellMetadata
):
void
{
// Don't apply metadata defaults here, 'undefined' means 'inherit from document metadata'
this
.
_metadataChangeListener
.
dispose
();
const
observableMetadata
=
getObservable
(
newMetadata
);
...
...
@@ -179,8 +185,6 @@ export class ExtHostCell extends Disposable implements vscode.NotebookCell {
this
.
_metadataChangeListener
=
this
.
_register
(
observableMetadata
.
onDidChange
(()
=>
{
this
.
_updateMetadata
();
}));
this
.
_updateMetadata
();
}
private
_updateMetadata
():
Promise
<
void
>
{
...
...
@@ -346,7 +350,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
get
isDirty
()
{
return
false
;
}
acc
pe
tModelChanged
(
event
:
NotebookCellsChangedEvent
):
void
{
acc
ep
tModelChanged
(
event
:
NotebookCellsChangedEvent
):
void
{
this
.
_versionId
=
event
.
versionId
;
if
(
event
.
kind
===
NotebookCellsChangeType
.
Initialize
)
{
this
.
$spliceNotebookCells
(
event
.
changes
,
true
);
...
...
@@ -360,6 +364,8 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
this
.
$clearAllCellOutputs
();
}
else
if
(
event
.
kind
===
NotebookCellsChangeType
.
ChangeLanguage
)
{
this
.
$changeCellLanguage
(
event
.
index
,
event
.
language
);
}
else
if
(
event
.
kind
===
NotebookCellsChangeType
.
ChangeMetadata
)
{
this
.
$changeCellMetadata
(
event
.
index
,
event
.
metadata
);
}
}
...
...
@@ -461,6 +467,13 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
this
.
_emitter
.
emitCellLanguageChange
(
event
);
}
private
$changeCellMetadata
(
index
:
number
,
newMetadata
:
NotebookCellMetadata
):
void
{
const
cell
=
this
.
cells
[
index
];
cell
.
setMetadata
(
newMetadata
);
const
event
:
vscode
.
NotebookCellMetadataChangeEvent
=
{
document
:
this
,
cell
};
this
.
_emitter
.
emitCellMetadataChange
(
event
);
}
async
eventuallyUpdateCellOutputs
(
cell
:
ExtHostCell
,
diffs
:
ISplice
<
IProcessedOutput
>
[])
{
let
renderers
=
new
Set
<
number
>
();
let
outputDtos
:
NotebookCellOutputsSplice
[]
=
diffs
.
map
(
diff
=>
{
...
...
@@ -888,6 +901,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
readonly
onDidChangeCellOutputs
=
this
.
_onDidChangeCellOutputs
.
event
;
private
readonly
_onDidChangeCellLanguage
=
new
Emitter
<
vscode
.
NotebookCellLanguageChangeEvent
>
();
readonly
onDidChangeCellLanguage
=
this
.
_onDidChangeCellLanguage
.
event
;
private
readonly
_onDidChangeCellMetadata
=
new
Emitter
<
vscode
.
NotebookCellMetadataChangeEvent
>
();
readonly
onDidChangeCellMetadata
=
this
.
_onDidChangeCellMetadata
.
event
;
private
readonly
_onDidChangeActiveNotebookEditor
=
new
Emitter
<
vscode
.
NotebookEditor
|
undefined
>
();
readonly
onDidChangeActiveNotebookEditor
=
this
.
_onDidChangeActiveNotebookEditor
.
event
;
...
...
@@ -1179,7 +1194,10 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
},
emitCellLanguageChange
(
event
:
vscode
.
NotebookCellLanguageChangeEvent
):
void
{
that
.
_onDidChangeCellLanguage
.
fire
(
event
);
}
},
emitCellMetadataChange
(
event
:
vscode
.
NotebookCellMetadataChangeEvent
):
void
{
that
.
_onDidChangeCellMetadata
.
fire
(
event
);
},
},
viewType
,
revivedUri
,
this
,
storageRoot
);
this
.
_unInitializedDocuments
.
set
(
revivedUri
.
toString
(),
document
);
}
...
...
@@ -1424,7 +1442,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
const
document
=
this
.
_documents
.
get
(
URI
.
revive
(
uriComponents
).
toString
());
if
(
document
)
{
document
.
acc
pe
tModelChanged
(
event
);
document
.
acc
ep
tModelChanged
(
event
);
}
}
...
...
@@ -1538,6 +1556,9 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
},
emitCellLanguageChange
(
event
:
vscode
.
NotebookCellLanguageChangeEvent
):
void
{
that
.
_onDidChangeCellLanguage
.
fire
(
event
);
},
emitCellMetadataChange
(
event
:
vscode
.
NotebookCellMetadataChangeEvent
):
void
{
that
.
_onDidChangeCellMetadata
.
fire
(
event
);
}
},
viewType
,
revivedUri
,
this
,
storageRoot
);
...
...
@@ -1549,7 +1570,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
};
}
document
.
acc
pe
tModelChanged
({
document
.
acc
ep
tModelChanged
({
kind
:
NotebookCellsChangeType
.
Initialize
,
versionId
:
modelData
.
versionId
,
changes
:
[[
...
...
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
浏览文件 @
eb05e94d
...
...
@@ -17,7 +17,7 @@ import { InputFocusedContext, InputFocusedContextKey } from 'vs/platform/context
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
QuickPickInput
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
BaseCellRenderTemplate
,
Cell
CollapseState
,
Cell
EditState
,
CellFocusMode
,
ICellViewModel
,
INotebookEditor
,
NOTEBOOK_CELL_INPUT_COLLAPSED
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
NOTEBOOK_CELL_LIST_FOCUSED
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_OUTPUT_COLLAPSED
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_EDITOR_EDITABLE
,
NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK
,
NOTEBOOK_EDITOR_FOCUSED
,
NOTEBOOK_EDITOR_RUNNABLE
,
NOTEBOOK_IS_ACTIVE_EDITOR
,
NOTEBOOK_OUTPUT_FOCUSED
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CellFocusMode
,
ICellViewModel
,
INotebookEditor
,
NOTEBOOK_CELL_INPUT_COLLAPSED
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
NOTEBOOK_CELL_LIST_FOCUSED
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_OUTPUT_COLLAPSED
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_EDITOR_EDITABLE
,
NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK
,
NOTEBOOK_EDITOR_FOCUSED
,
NOTEBOOK_EDITOR_RUNNABLE
,
NOTEBOOK_IS_ACTIVE_EDITOR
,
NOTEBOOK_OUTPUT_FOCUSED
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
CellKind
,
CellUri
,
NotebookCellRunState
,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
...
...
@@ -1314,7 +1314,7 @@ registerAction2(class extends NotebookCellAction {
}
async
runWithContext
(
accessor
:
ServicesAccessor
,
context
:
INotebookCellActionContext
):
Promise
<
void
>
{
context
.
cell
.
collapseState
=
CellCollapseState
.
Collapsed
;
context
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
changeCellMetadata
(
context
.
cell
.
handle
,
{
inputCollapsed
:
true
})
;
}
});
...
...
@@ -1337,7 +1337,7 @@ registerAction2(class extends NotebookCellAction {
}
async
runWithContext
(
accessor
:
ServicesAccessor
,
context
:
INotebookCellActionContext
):
Promise
<
void
>
{
context
.
cell
.
collapseState
=
CellCollapseState
.
Normal
;
context
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
changeCellMetadata
(
context
.
cell
.
handle
,
{
inputCollapsed
:
false
})
;
}
});
...
...
@@ -1360,7 +1360,7 @@ registerAction2(class extends NotebookCellAction {
}
async
runWithContext
(
accessor
:
ServicesAccessor
,
context
:
INotebookCellActionContext
):
Promise
<
void
>
{
context
.
cell
.
outputCollapseState
=
CellCollapseState
.
Collapsed
;
context
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
changeCellMetadata
(
context
.
cell
.
handle
,
{
outputCollapsed
:
true
})
;
}
});
...
...
@@ -1383,6 +1383,6 @@ registerAction2(class extends NotebookCellAction {
}
async
runWithContext
(
accessor
:
ServicesAccessor
,
context
:
INotebookCellActionContext
):
Promise
<
void
>
{
context
.
cell
.
outputCollapseState
=
CellCollapseState
.
Normal
;
context
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
changeCellMetadata
(
context
.
cell
.
handle
,
{
inputCollapsed
:
false
})
;
}
});
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
eb05e94d
...
...
@@ -113,8 +113,6 @@ export interface ICellViewModel {
readonly
model
:
NotebookCellTextModel
;
readonly
id
:
string
;
readonly
textBuffer
:
IReadonlyTextBuffer
;
collapseState
:
CellCollapseState
;
outputCollapseState
:
CellCollapseState
;
dragging
:
boolean
;
handle
:
number
;
uri
:
URI
;
...
...
@@ -547,11 +545,6 @@ export enum CellEditState {
Editing
}
export
enum
CellCollapseState
{
Normal
,
Collapsed
}
export
enum
CellFocusMode
{
Container
,
Editor
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
浏览文件 @
eb05e94d
...
...
@@ -14,7 +14,7 @@ import * as UUID from 'vs/base/common/uuid';
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IOpenerService
,
matchesScheme
}
from
'
vs/platform/opener/common/opener
'
;
import
{
CELL_MARGIN
,
CELL_RUN_GUTTER
,
CODE_CELL_LEFT_MARGIN
,
CELL_OUTPUT_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellCollapseState
,
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CodeCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel
'
;
import
{
CellOutputKind
,
IProcessedOutput
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
...
...
@@ -561,7 +561,7 @@ ${loaderJs}
return
;
}
if
(
cell
.
outputCollapseState
===
CellCollapseState
.
Collapsed
)
{
if
(
cell
.
metadata
?.
output
Collapsed
)
{
return
false
;
}
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys.ts
浏览文件 @
eb05e94d
...
...
@@ -6,7 +6,7 @@
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
INotebookTextModel
,
NotebookCellRunState
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
BaseCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel
'
;
import
{
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_VIEW_TYPE
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_RUNNABLE
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_RUN_STATE
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
CellViewModelStateChangeEvent
,
CellEditState
,
NOTEBOOK_CELL_INPUT_COLLAPSED
,
CellCollapseState
,
NOTEBOOK_CELL_OUTPUT_COLLAPSED
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_VIEW_TYPE
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_RUNNABLE
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_RUN_STATE
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
CellViewModelStateChangeEvent
,
CellEditState
,
NOTEBOOK_CELL_INPUT_COLLAPSED
,
NOTEBOOK_CELL_OUTPUT_COLLAPSED
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CodeCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel
'
;
import
{
MarkdownCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel
'
;
import
{
Disposable
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
...
...
@@ -109,8 +109,8 @@ export class CellContextKeyManager extends Disposable {
}
private
updateForCollapseState
()
{
this
.
cellContentCollapsed
.
set
(
this
.
element
.
collapseState
===
CellCollapseState
.
Collapsed
);
this
.
cellOutputCollapsed
.
set
(
this
.
element
.
outputCollapseState
===
CellCollapseState
.
Collapsed
);
this
.
cellContentCollapsed
.
set
(
!!
this
.
element
.
metadata
?.
input
Collapsed
);
this
.
cellOutputCollapsed
.
set
(
!!
this
.
element
.
metadata
?.
output
Collapsed
);
}
private
updateForOutputs
()
{
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
eb05e94d
...
...
@@ -38,7 +38,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
BOTTOM_CELL_TOOLBAR_HEIGHT
,
CELL_BOTTOM_MARGIN
,
CELL_TOP_MARGIN
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CancelCellAction
,
ChangeCellLanguageAction
,
ExecuteCellAction
,
INotebookCellActionContext
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
BaseCellRenderTemplate
,
Cell
CollapseState
,
Cell
EditState
,
CodeCellRenderTemplate
,
ICellViewModel
,
INotebookCellList
,
INotebookEditor
,
isCodeCellRenderTemplate
,
MarkdownCellRenderTemplate
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CodeCellRenderTemplate
,
ICellViewModel
,
INotebookCellList
,
INotebookEditor
,
isCodeCellRenderTemplate
,
MarkdownCellRenderTemplate
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellContextKeyManager
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys
'
;
import
{
CellMenus
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellMenus
'
;
import
{
CodeCell
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/codeCell
'
;
...
...
@@ -317,10 +317,10 @@ abstract class AbstractCellRenderer {
return
;
}
if
(
templateData
.
currentRenderedCell
.
collapseState
===
CellCollapseState
.
Collapsed
)
{
t
emplateData
.
currentRenderedCell
.
collapseState
=
CellCollapseState
.
Normal
;
}
else
if
(
templateData
.
currentRenderedCell
.
outputCollapseState
===
CellCollapseState
.
Collapsed
)
{
t
emplateData
.
currentRenderedCell
.
outputCollapseState
=
CellCollapseState
.
Normal
;
if
(
templateData
.
currentRenderedCell
.
metadata
?.
input
Collapsed
)
{
t
his
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
changeCellMetadata
(
templateData
.
currentRenderedCell
.
handle
,
{
inputCollapsed
:
false
})
;
}
else
if
(
templateData
.
currentRenderedCell
.
metadata
?.
output
Collapsed
)
{
t
his
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
changeCellMetadata
(
templateData
.
currentRenderedCell
.
handle
,
{
outputCollapsed
:
false
})
;
}
}));
}
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
浏览文件 @
eb05e94d
...
...
@@ -11,7 +11,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import
*
as
nls
from
'
vs/nls
'
;
import
{
IQuickInputService
,
IQuickPickItem
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
Cell
CollapseState
,
Cell
FocusMode
,
CodeCellRenderTemplate
,
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellFocusMode
,
CodeCellRenderTemplate
,
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
getResizesObserver
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/sizeObserver
'
;
import
{
CodeCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel
'
;
...
...
@@ -305,11 +305,11 @@ export class CodeCell extends Disposable {
}
private
viewUpdate
():
void
{
if
(
this
.
viewCell
.
collapseState
===
CellCollapseState
.
Collapsed
&&
this
.
viewCell
.
outputCollapseState
===
CellCollapseState
.
Collapsed
)
{
if
(
this
.
viewCell
.
metadata
?.
inputCollapsed
&&
this
.
viewCell
.
metadata
.
output
Collapsed
)
{
this
.
viewUpdateAllCollapsed
();
}
else
if
(
this
.
viewCell
.
collapseState
===
CellCollapseState
.
Collapsed
)
{
}
else
if
(
this
.
viewCell
.
metadata
?.
input
Collapsed
)
{
this
.
viewUpdateInputCollapsed
();
}
else
if
(
this
.
viewCell
.
outputCollapseState
===
CellCollapseState
.
Collapsed
&&
this
.
viewCell
.
outputs
.
length
)
{
}
else
if
(
this
.
viewCell
.
metadata
?.
output
Collapsed
&&
this
.
viewCell
.
outputs
.
length
)
{
this
.
viewUpdateOutputCollapsed
();
}
else
{
this
.
viewUpdateExpanded
();
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
浏览文件 @
eb05e94d
...
...
@@ -12,7 +12,7 @@ import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
INotebookEditor
,
MarkdownCellRenderTemplate
,
ICellViewModel
,
CellCollapseState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellEditState
,
CellFocusMode
,
INotebookEditor
,
MarkdownCellRenderTemplate
,
ICellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellFoldingState
}
from
'
vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel
'
;
import
{
MarkdownCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
...
...
@@ -132,7 +132,7 @@ export class StatefulMarkdownCell extends Disposable {
}
private
viewUpdate
():
void
{
if
(
this
.
viewCell
.
collapseState
===
CellCollapseState
.
Collapsed
)
{
if
(
this
.
viewCell
.
metadata
?.
input
Collapsed
)
{
this
.
viewUpdateCollapsed
();
}
else
if
(
this
.
viewCell
.
editState
===
CellEditState
.
Editing
)
{
this
.
viewUpdateEditing
();
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
浏览文件 @
eb05e94d
...
...
@@ -13,7 +13,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
CursorAtBoundary
,
CellViewModelStateChangeEvent
,
IEditableCellViewModel
,
INotebookCellDecorationOptions
,
CellCollapseState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellEditState
,
CellFocusMode
,
CursorAtBoundary
,
CellViewModelStateChangeEvent
,
IEditableCellViewModel
,
INotebookCellDecorationOptions
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
...
...
@@ -60,28 +60,6 @@ export abstract class BaseCellViewModel extends Disposable {
}
}
public
get
collapseState
():
CellCollapseState
{
return
this
.
metadata
?.
inputCollapsed
?
CellCollapseState
.
Collapsed
:
CellCollapseState
.
Normal
;
}
public
set
collapseState
(
v
:
CellCollapseState
)
{
this
.
model
.
metadata
=
{
...
this
.
metadata
,
...{
inputCollapsed
:
v
===
CellCollapseState
.
Collapsed
}
};
}
public
get
outputCollapseState
():
CellCollapseState
{
return
this
.
metadata
?.
outputCollapsed
?
CellCollapseState
.
Collapsed
:
CellCollapseState
.
Normal
;
}
public
set
outputCollapseState
(
v
:
CellCollapseState
)
{
this
.
model
.
metadata
=
{
...
this
.
metadata
,
...{
outputCollapsed
:
v
===
CellCollapseState
.
Collapsed
}
};
}
private
_focusMode
:
CellFocusMode
=
CellFocusMode
.
Container
;
get
focusMode
()
{
return
this
.
_focusMode
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
浏览文件 @
eb05e94d
...
...
@@ -9,7 +9,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
BOTTOM_CELL_TOOLBAR_HEIGHT
,
CELL_MARGIN
,
CELL_RUN_GUTTER
,
CELL_STATUSBAR_HEIGHT
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
CELL_TOP_MARGIN
,
EDITOR_TOP_PADDING
,
CELL_BOTTOM_MARGIN
,
CODE_CELL_LEFT_MARGIN
,
BOTTOM_CELL_TOOLBAR_OFFSET
,
COLLAPSED_INDICATOR_HEIGHT
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFindMatch
,
CodeCellLayoutChangeEvent
,
CodeCellLayoutInfo
,
ICellViewModel
,
NotebookLayoutInfo
,
CodeCellLayoutState
,
CellCollapseState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellEditState
,
CellFindMatch
,
CodeCellLayoutChangeEvent
,
CodeCellLayoutInfo
,
ICellViewModel
,
NotebookLayoutInfo
,
CodeCellLayoutState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
NotebookCellOutputsSplice
,
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
BaseCellViewModel
}
from
'
./baseCellViewModel
'
;
...
...
@@ -99,9 +99,9 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
layoutChange
(
state
:
CodeCellLayoutChangeEvent
)
{
// recompute
this
.
_ensureOutputsTop
();
let
outputTotalHeight
=
this
.
outputCollapseState
===
CellCollapseState
.
Normal
?
this
.
_outputsTop
!
.
getTotalValue
()
:
COLLAPSED_INDICATOR_HEIGHT
;
let
outputTotalHeight
=
this
.
metadata
?.
outputCollapsed
?
COLLAPSED_INDICATOR_HEIGHT
:
this
.
_outputsTop
!
.
getTotalValue
()
;
if
(
this
.
collapseState
===
CellCollapseState
.
Normal
)
{
if
(
!
this
.
metadata
?.
inputCollapsed
)
{
let
newState
:
CodeCellLayoutState
;
let
editorHeight
:
number
;
let
totalHeight
:
number
;
...
...
@@ -138,7 +138,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
layoutState
:
newState
};
}
else
{
outputTotalHeight
=
this
.
collapseState
===
CellCollapseState
.
Collapsed
&&
this
.
outputCollapseState
===
CellCollapseState
.
Collapsed
?
0
:
outputTotalHeight
;
outputTotalHeight
=
this
.
metadata
?.
inputCollapsed
&&
this
.
metadata
.
output
Collapsed
?
0
:
outputTotalHeight
;
const
indicatorHeight
=
COLLAPSED_INDICATOR_HEIGHT
+
outputTotalHeight
;
const
outputContainerOffset
=
CELL_TOP_MARGIN
+
COLLAPSED_INDICATOR_HEIGHT
;
const
totalHeight
=
CELL_TOP_MARGIN
+
COLLAPSED_INDICATOR_HEIGHT
+
CELL_BOTTOM_MARGIN
+
BOTTOM_CELL_TOOLBAR_HEIGHT
+
outputTotalHeight
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel.ts
浏览文件 @
eb05e94d
...
...
@@ -9,7 +9,7 @@ import * as UUID from 'vs/base/common/uuid';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
BOTTOM_CELL_TOOLBAR_HEIGHT
,
CELL_MARGIN
,
CELL_STATUSBAR_HEIGHT
,
CELL_TOP_MARGIN
,
CELL_BOTTOM_MARGIN
,
CODE_CELL_LEFT_MARGIN
,
BOTTOM_CELL_TOOLBAR_OFFSET
,
COLLAPSED_INDICATOR_HEIGHT
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
Cell
CollapseState
,
Cell
FindMatch
,
ICellViewModel
,
MarkdownCellLayoutChangeEvent
,
MarkdownCellLayoutInfo
,
NotebookLayoutInfo
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellFindMatch
,
ICellViewModel
,
MarkdownCellLayoutChangeEvent
,
MarkdownCellLayoutInfo
,
NotebookLayoutInfo
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
MarkdownRenderer
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/mdRenderer
'
;
import
{
BaseCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel
'
;
import
{
EditorFoldingStateDelegate
}
from
'
vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel
'
;
...
...
@@ -93,7 +93,7 @@ export class MarkdownCellViewModel extends BaseCellViewModel implements ICellVie
layoutChange
(
state
:
MarkdownCellLayoutChangeEvent
)
{
// recompute
if
(
this
.
collapseState
===
CellCollapseState
.
Normal
)
{
if
(
!
this
.
metadata
?.
inputCollapsed
)
{
const
editorWidth
=
state
.
outerWidth
!==
undefined
?
this
.
computeEditorWidth
(
state
.
outerWidth
)
:
this
.
_layoutInfo
.
editorWidth
;
const
totalHeight
=
state
.
totalHeight
===
undefined
?
this
.
_layoutInfo
.
totalHeight
:
state
.
totalHeight
;
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
eb05e94d
...
...
@@ -527,6 +527,19 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
}
}
changeCellMetadata
(
handle
:
number
,
newMetadata
:
NotebookCellMetadata
)
{
const
cell
=
this
.
_mapping
.
get
(
handle
);
if
(
cell
)
{
cell
.
metadata
=
{
...
cell
.
metadata
,
...
newMetadata
};
this
.
_increaseVersionId
();
this
.
_onDidModelChangeProxy
.
fire
({
kind
:
NotebookCellsChangeType
.
ChangeMetadata
,
versionId
:
this
.
_versionId
,
index
:
this
.
cells
.
indexOf
(
cell
),
metadata
:
newMetadata
});
}
}
clearAllCellOutputs
()
{
this
.
cells
.
forEach
(
cell
=>
{
cell
.
spliceNotebookCellOutputs
([
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
eb05e94d
...
...
@@ -325,7 +325,8 @@ export enum NotebookCellsChangeType {
CellClearOutput
=
3
,
CellsClearOutput
=
4
,
ChangeLanguage
=
5
,
Initialize
=
6
Initialize
=
6
,
ChangeMetadata
=
7
}
export
interface
NotebookCellsInitializeEvent
{
...
...
@@ -365,7 +366,14 @@ export interface NotebookCellsChangeLanguageEvent {
readonly
language
:
string
;
}
export
type
NotebookCellsChangedEvent
=
NotebookCellsInitializeEvent
|
NotebookCellsModelChangedEvent
|
NotebookCellsModelMoveEvent
|
NotebookCellClearOutputEvent
|
NotebookCellsClearOutputEvent
|
NotebookCellsChangeLanguageEvent
;
export
interface
NotebookCellsChangeMetadataEvent
{
readonly
kind
:
NotebookCellsChangeType
.
ChangeMetadata
;
readonly
versionId
:
number
;
readonly
index
:
number
;
readonly
metadata
:
NotebookCellMetadata
;
}
export
type
NotebookCellsChangedEvent
=
NotebookCellsInitializeEvent
|
NotebookCellsModelChangedEvent
|
NotebookCellsModelMoveEvent
|
NotebookCellClearOutputEvent
|
NotebookCellsClearOutputEvent
|
NotebookCellsChangeLanguageEvent
|
NotebookCellsChangeMetadataEvent
;
export
enum
CellEditType
{
Insert
=
1
,
Delete
=
2
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录