Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
dcf665a2
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,发现更多精彩内容 >>
提交
dcf665a2
编写于
3月 20, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
layout info for code cell
上级
d9e6da61
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
71 addition
and
39 deletion
+71
-39
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
...ntrib/notebook/browser/view/renderers/backLayerWebView.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
...bench/contrib/notebook/browser/view/renderers/codeCell.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
...h/contrib/notebook/browser/viewModel/baseCellViewModel.ts
+1
-10
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
...h/contrib/notebook/browser/viewModel/codeCellViewModel.ts
+62
-21
未找到文件。
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
浏览文件 @
dcf665a2
...
...
@@ -278,7 +278,7 @@ export class BackLayerWebView extends Disposable {
if
(
cell
)
{
let
outputIndex
=
cell
.
outputs
.
indexOf
(
output
);
cell
.
updateOutputHeight
(
outputIndex
,
outputHeight
);
this
.
notebookEditor
.
layoutNotebookCell
(
cell
,
cell
.
getCellTotalHeight
()
);
this
.
notebookEditor
.
layoutNotebookCell
(
cell
,
cell
.
layoutInfo
.
totalHeight
);
}
}
else
if
(
data
.
type
===
'
scroll-ack
'
)
{
// const date = new Date();
...
...
@@ -310,7 +310,7 @@ export class BackLayerWebView extends Disposable {
let
outputIndex
=
cell
.
outputs
.
indexOf
(
output
);
let
outputOffsetInOutputContainer
=
cell
.
getOutputOffset
(
outputIndex
);
let
outputOffset
=
cellTop
+
cell
.
editorHeight
+
16
/* editor padding */
+
8
+
outputOffsetInOutputContainer
;
let
outputOffset
=
cellTop
+
cell
.
layoutInfo
.
editorHeight
+
16
/* editor padding */
+
8
+
outputOffsetInOutputContainer
;
if
(
outputOffset
===
outputCache
.
cacheOffset
)
{
return
false
;
...
...
@@ -326,7 +326,7 @@ export class BackLayerWebView extends Disposable {
let
outputIndex
=
item
.
cell
.
outputs
.
indexOf
(
item
.
output
);
let
outputOffsetInOutputContainer
=
item
.
cell
.
getOutputOffset
(
outputIndex
);
let
outputOffset
=
item
.
cellTop
+
item
.
cell
.
editorHeight
+
16
/* editor padding */
+
16
+
outputOffsetInOutputContainer
;
let
outputOffset
=
item
.
cellTop
+
item
.
cell
.
layoutInfo
.
editorHeight
+
16
/* editor padding */
+
16
+
outputOffsetInOutputContainer
;
outputCache
.
cacheOffset
=
outputOffset
;
return
{
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
dcf665a2
...
...
@@ -387,8 +387,8 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
elementDisposable
?.
add
(
this
.
instantiationService
.
createInstance
(
CodeCell
,
this
.
notebookEditor
,
element
,
templateData
));
this
.
renderedEditors
.
set
(
element
,
templateData
.
editor
);
elementDisposable
?.
add
(
element
.
onDidChange
TotalHeigh
t
(()
=>
{
templateData
.
focusIndicator
!
.
style
.
height
=
`
${
element
.
getIndicatorHeight
()
}
px`
;
elementDisposable
?.
add
(
element
.
onDidChange
Layou
t
(()
=>
{
templateData
.
focusIndicator
!
.
style
.
height
=
`
${
element
.
layoutInfo
.
indicatorHeight
}
px`
;
}));
const
toolbarContext
=
<
INotebookCellActionContext
>
{
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
浏览文件 @
dcf665a2
...
...
@@ -106,7 +106,7 @@ export class CodeCell extends Disposable {
this
.
_register
(
templateData
.
editor
!
.
onDidContentSizeChange
((
e
)
=>
{
if
(
e
.
contentHeightChanged
)
{
if
(
this
.
viewCell
.
editorHeight
!==
e
.
contentHeight
)
{
if
(
this
.
viewCell
.
layoutInfo
.
editorHeight
!==
e
.
contentHeight
)
{
let
viewLayout
=
templateData
.
editor
!
.
getLayoutInfo
();
templateData
.
editor
?.
layout
(
...
...
@@ -256,7 +256,7 @@ export class CodeCell extends Disposable {
if
(
result
.
shadowContent
)
{
this
.
viewCell
.
selfSizeMonitoring
=
true
;
let
editorHeight
=
this
.
viewCell
.
editorHeight
;
let
editorHeight
=
this
.
viewCell
.
layoutInfo
.
editorHeight
;
this
.
notebookEditor
.
createInset
(
this
.
viewCell
,
currOutput
,
result
.
shadowContent
,
editorHeight
+
8
+
this
.
viewCell
.
getOutputOffset
(
index
));
}
else
{
DOM
.
addClass
(
outputItemDiv
,
'
foreground
'
);
...
...
@@ -369,7 +369,7 @@ export class CodeCell extends Disposable {
}
relayoutCell
()
{
this
.
notebookEditor
.
layoutNotebookCell
(
this
.
viewCell
,
this
.
viewCell
.
getCellTotalHeight
()
);
this
.
notebookEditor
.
layoutNotebookCell
(
this
.
viewCell
,
this
.
viewCell
.
layoutInfo
.
totalHeight
);
}
dispose
()
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
浏览文件 @
dcf665a2
...
...
@@ -21,8 +21,6 @@ export abstract class BaseCellViewModel extends Disposable {
readonly
onDidChangeCellState
=
this
.
_onDidChangeCellState
.
event
;
protected
readonly
_onDidChangeFocusMode
=
new
Emitter
<
void
>
();
readonly
onDidChangeFocusMode
=
this
.
_onDidChangeFocusMode
.
event
;
protected
readonly
_onDidChangeTotalHeight
=
new
Emitter
<
void
>
();
readonly
onDidChangeTotalHeight
=
this
.
_onDidChangeTotalHeight
.
event
;
protected
readonly
_onDidChangeEditorAttachState
=
new
Emitter
<
boolean
>
();
readonly
onDidChangeEditorAttachState
=
this
.
_onDidChangeEditorAttachState
.
event
;
protected
readonly
_onDidChangeCursorSelection
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
...
...
@@ -58,14 +56,7 @@ export abstract class BaseCellViewModel extends Disposable {
this
.
_focusMode
=
newMode
;
this
.
_onDidChangeFocusMode
.
fire
();
}
private
_editorHeight
=
0
;
set
editorHeight
(
height
:
number
)
{
this
.
_editorHeight
=
height
;
this
.
_onDidChangeTotalHeight
.
fire
();
}
get
editorHeight
():
number
{
return
this
.
_editorHeight
;
}
protected
_textEditor
?:
ICodeEditor
;
get
editorAttached
():
boolean
{
return
!!
this
.
_textEditor
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
浏览文件 @
dcf665a2
...
...
@@ -13,6 +13,19 @@ import { CellState, ICellViewModel, CellFindMatch } from 'vs/workbench/contrib/n
import
{
CellKind
,
ICell
,
NotebookCellOutputsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
BaseCellViewModel
}
from
'
./baseCellViewModel
'
;
export
interface
CodeCellLayoutInfo
{
readonly
editorHeight
:
number
;
readonly
totalHeight
:
number
;
readonly
outputTotalHeight
:
number
;
readonly
indicatorHeight
:
number
;
}
export
interface
CodeCellLayoutChangeEvent
{
editorHeight
?:
boolean
;
outputHeight
?:
boolean
;
totalHeight
?:
boolean
;
}
export
class
CodeCellViewModel
extends
BaseCellViewModel
implements
ICellViewModel
{
cellKind
:
CellKind
.
Code
=
CellKind
.
Code
;
protected
readonly
_onDidChangeOutputs
=
new
Emitter
<
NotebookCellOutputsSplice
[]
>
();
...
...
@@ -35,6 +48,22 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
private
readonly
_onDidChangeContent
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidChangeContent
:
Event
<
void
>
=
this
.
_onDidChangeContent
.
event
;
protected
readonly
_onDidChangeLayout
=
new
Emitter
<
CodeCellLayoutChangeEvent
>
();
readonly
onDidChangeLayout
=
this
.
_onDidChangeLayout
.
event
;
private
_editorHeight
=
0
;
set
editorHeight
(
height
:
number
)
{
this
.
_editorHeight
=
height
;
this
.
layoutChange
({
editorHeight
:
true
});
}
private
_layoutInfo
:
CodeCellLayoutInfo
;
get
layoutInfo
()
{
return
this
.
_layoutInfo
;
}
constructor
(
readonly
viewType
:
string
,
readonly
notebookHandle
:
number
,
...
...
@@ -52,6 +81,36 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
this
.
_outputCollection
=
new
Array
(
this
.
cell
.
outputs
.
length
);
this
.
_buffer
=
null
;
this
.
_layoutInfo
=
{
editorHeight
:
0
,
outputTotalHeight
:
0
,
totalHeight
:
0
,
indicatorHeight
:
0
};
}
layoutChange
(
state
:
CodeCellLayoutChangeEvent
)
{
// recompute
this
.
_ensureOutputsTop
();
const
outputTotalHeight
=
this
.
_outputsTop
!
.
getTotalValue
();
const
totalHeight
=
this
.
outputs
.
length
?
EDITOR_TOOLBAR_HEIGHT
+
this
.
editorHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
+
16
+
outputTotalHeight
:
EDITOR_TOOLBAR_HEIGHT
+
this
.
editorHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
+
outputTotalHeight
;
const
indicatorHeight
=
totalHeight
-
EDITOR_TOOLBAR_HEIGHT
-
16
;
this
.
_layoutInfo
=
{
editorHeight
:
this
.
_editorHeight
,
outputTotalHeight
,
totalHeight
,
indicatorHeight
};
if
(
state
.
editorHeight
||
state
.
outputHeight
)
{
state
.
totalHeight
=
true
;
}
this
.
_onDidChangeLayout
.
fire
(
state
);
}
hasDynamicHeight
()
{
...
...
@@ -117,7 +176,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
this
.
_outputCollection
[
index
]
=
height
;
this
.
_ensureOutputsTop
();
this
.
_outputsTop
!
.
changeValue
(
index
,
height
);
this
.
_onDidChangeTotalHeight
.
fire
(
);
this
.
layoutChange
({
outputHeight
:
true
}
);
}
getOutputOffset
(
index
:
number
):
number
{
...
...
@@ -130,12 +189,6 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
return
this
.
_outputsTop
!
.
getAccumulatedValue
(
index
-
1
);
}
private
getOutputTotalHeight
():
number
{
this
.
_ensureOutputsTop
();
return
this
.
_outputsTop
!
.
getTotalValue
();
}
spliceOutputHeights
(
start
:
number
,
deleteCnt
:
number
,
heights
:
number
[])
{
this
.
_ensureOutputsTop
();
...
...
@@ -149,22 +202,10 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
this
.
_outputsTop
!
.
insertValues
(
start
,
values
);
}
this
.
_onDidChangeTotalHeight
.
fire
();
}
getCellTotalHeight
():
number
{
if
(
this
.
outputs
.
length
)
{
return
EDITOR_TOOLBAR_HEIGHT
+
this
.
editorHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
+
16
+
this
.
getOutputTotalHeight
();
}
else
{
return
EDITOR_TOOLBAR_HEIGHT
+
this
.
editorHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
+
this
.
getOutputTotalHeight
();
}
}
getIndicatorHeight
():
number
{
return
this
.
getCellTotalHeight
()
-
EDITOR_TOOLBAR_HEIGHT
-
16
;
this
.
layoutChange
({
outputHeight
:
true
});
}
pr
otected
_ensureOutputsTop
():
void
{
pr
ivate
_ensureOutputsTop
():
void
{
if
(
!
this
.
_outputsTop
)
{
const
values
=
new
Uint32Array
(
this
.
_outputCollection
.
length
);
for
(
let
i
=
0
;
i
<
this
.
_outputCollection
.
length
;
i
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录