提交 30f6143a 编写于 作者: R rebornix

layout debouncing for output change.

上级 a3b8f79f
......@@ -16,6 +16,7 @@ import { INotebookService } from 'vs/workbench/contrib/notebook/browser/notebook
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { EDITOR_TOP_PADDING, EDITOR_BOTTOM_PADDING } from 'vs/workbench/contrib/notebook/browser/constants';
import { IModeService } from 'vs/editor/common/services/modeService';
import { debounce } from 'vs/base/common/decorators';
interface IMimeTypeRenderer extends IQuickPickItem {
index: number;
......@@ -196,7 +197,7 @@ export class CodeCell extends Disposable {
let editorHeight = templateData.editor!.getContentHeight();
viewCell.editorHeight = editorHeight;
this.relayoutCell();
this.relayoutCellDebounced();
}));
if (viewCell.outputs.length > 0) {
......@@ -382,6 +383,11 @@ export class CodeCell extends Disposable {
this.notebookEditor.layoutNotebookCell(this.viewCell, this.viewCell.layoutInfo.totalHeight);
}
@debounce(500)
relayoutCellDebounced() {
this.notebookEditor.layoutNotebookCell(this.viewCell, this.viewCell.layoutInfo.totalHeight);
}
dispose() {
this.viewCell.detachTextEditor();
this.outputResizeListeners.forEach((value) => {
......
......@@ -13,6 +13,7 @@ import { CellEditState, ICellViewModel, CellFindMatch, CodeCellLayoutChangeEvent
import { CellKind, ICell, NotebookCellOutputsSplice } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { BaseCellViewModel } from './baseCellViewModel';
import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher';
import { debounce } from 'vs/base/common/decorators';
export class CodeCellViewModel extends BaseCellViewModel implements ICellViewModel {
cellKind: CellKind.Code = CellKind.Code;
......@@ -36,7 +37,7 @@ 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>();
protected readonly _onDidChangeLayout = new Emitter<void>();
readonly onDidChangeLayout = this._onDidChangeLayout.event;
private _editorHeight = 0;
......@@ -125,7 +126,12 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
state.totalHeight = true;
}
this._onDidChangeLayout.fire(state);
this._fireOnDidChangeLayout();
}
@debounce(100)
private _fireOnDidChangeLayout() {
this._onDidChangeLayout.fire();
}
hasDynamicHeight() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册