Skip to content

Commit

Permalink
fix output max height update for diff editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Apr 20, 2021
1 parent 8fa6582 commit 65273f8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,28 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
}
}

scheduleOutputHeightAck() { }
scheduleOutputHeightAck(cellInfo: IDiffCellInfo, outputId: string, height: number) {
const diffElement = cellInfo.diffElement;
// const activeWebview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
let diffSide = DiffSide.Original;

if (diffElement instanceof SideBySideDiffElementViewModel) {
const info = CellUri.parse(cellInfo.cellUri);
if (!info) {
return;
}

diffSide = info.notebook.toString() === this._model?.original.resource.toString() ? DiffSide.Original : DiffSide.Modified;
} else {
diffSide = diffElement.type === 'insert' ? DiffSide.Modified : DiffSide.Original;
}

const webview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;

DOM.scheduleAtNextAnimationFrame(() => {
webview?.ackHeight(cellInfo.cellId, outputId, height);
}, 10);
}

private _computeModifiedLCS(change: IDiffChange, originalModel: NotebookTextModel, modifiedModel: NotebookTextModel) {
const result: DiffElementViewModelBase[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export interface ICommonNotebookEditor {
focusNotebookCell(cell: IGenericCellViewModel, focus: 'editor' | 'container' | 'output', options?: IFocusNotebookCellOptions): void;
focusNextNotebookCell(cell: IGenericCellViewModel, focus: 'editor' | 'container' | 'output'): void;
updateOutputHeight(cellInfo: ICommonCellInfo, output: IDisplayOutputViewModel, height: number, isInit: boolean, source?: string): void;
scheduleOutputHeightAck(cellId: string, outputId: string, height: number): void;
scheduleOutputHeightAck(cellInfo: ICommonCellInfo, outputId: string, height: number): void;
updateMarkdownCellHeight(cellId: string, height: number, isInit: boolean): void;
setMarkdownCellEditState(cellId: string, editState: CellEditState): void;
markdownCellDragStart(cellId: string, position: { clientY: number }): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2355,12 +2355,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
}
}

scheduleOutputHeightAck(cellId: string, outputId: string, height: number) {
scheduleOutputHeightAck(cellInfo: ICommonCellInfo, outputId: string, height: number) {
DOM.scheduleAtNextAnimationFrame(() => {
this.updateScrollHeight();

this._debug('ack height', height);
this._webview?.ackHeight(cellId, outputId, height);
this._webview?.ackHeight(cellInfo.cellId, outputId, height);
}, 10);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ var requirejs = (function() {
if (resolvedResult) {
const { cellInfo, output } = resolvedResult;
this.notebookEditor.updateOutputHeight(cellInfo, output, height, !!update.init, 'webview#dimension');
this.notebookEditor.scheduleOutputHeightAck(cellInfo.cellId, update.id, height);
this.notebookEditor.scheduleOutputHeightAck(cellInfo, update.id, height);
}
} else {
this.notebookEditor.updateMarkdownCellHeight(update.id, height, !!update.init);
Expand Down

0 comments on commit 65273f8

Please sign in to comment.