Skip to content

Commit

Permalink
Fix editors with wrapped text not being layed out correctly after rel…
Browse files Browse the repository at this point in the history
…oading the window (#177027)
  • Loading branch information
roblourens committed Mar 14, 2023
1 parent 93eaf7c commit bbe8e87
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,7 @@ export class InteractiveListItemRenderer extends Disposable implements ITreeRend
private renderCodeBlock(data: IInteractiveResultCodeBlockData, disposables: DisposableStore): IDisposableReference<IInteractiveResultCodeBlockPart> {
const ref = this._editorPool.get();
const editorInfo = ref.object;
editorInfo.render(data);

const layoutEditor = (context: string) => {
editorInfo.layout(this._currentLayoutWidth);
};

layoutEditor('init');

disposables.add(editorInfo.textModel.onDidChangeContent(() => {
layoutEditor('textmodel');
}));
editorInfo.render(data, this._currentLayoutWidth);

return ref;
}
Expand Down Expand Up @@ -427,7 +417,7 @@ interface IInteractiveResultCodeBlockPart {
readonly element: HTMLElement;
readonly textModel: ITextModel;
layout(width: number): void;
render(data: IInteractiveResultCodeBlockData): void;
render(data: IInteractiveResultCodeBlockData, width: number): void;
dispose(): void;
}

Expand Down Expand Up @@ -529,10 +519,20 @@ class CodeBlockPart extends Disposable implements IInteractiveResultCodeBlockPar
this.editor.layout({ width, height: realContentHeight });
}

render(data: IInteractiveResultCodeBlockData): void {
render(data: IInteractiveResultCodeBlockData, width: number): void {
this.contextKeyService.updateParent(data.parentContextKeyService);

if (this.options.configuration.resultEditor.wordWrap === 'on') {
// Intialize the editor with the new proper width so that getContentHeight
// will be computed correctly in the next call to layout()
this.layout(width);
}

this.setText(data.text);
this.setLanguage(data.languageId);

this.layout(width);

this.toolbar.context = <IInteractiveSessionCodeBlockActionContext>{
code: data.text,
codeBlockIndex: data.index,
Expand Down

0 comments on commit bbe8e87

Please sign in to comment.