Skip to content

Commit 77a8acf

Browse files
committed
don't rerender the same output
1 parent 4c2df56 commit 77a8acf

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

extensions/notebook-renderers/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ function renderStream(outputInfo: OutputWithAppend, outputElement: HTMLElement,
281281

282282
outputElement.classList.add('output-stream');
283283

284-
285-
286284
const scrollTop = outputScrolling ? findScrolledHeight(outputElement) : undefined;
287285

288286
const previousOutputParent = getPreviousMatchingContentGroup(outputElement);
@@ -302,8 +300,9 @@ function renderStream(outputInfo: OutputWithAppend, outputElement: HTMLElement,
302300
const existingContent = outputElement.querySelector(`[output-item-id="${outputInfo.id}"]`) as HTMLElement | null;
303301
let contentParent = existingContent?.parentElement;
304302
if (existingContent && contentParent) {
305-
if (appendedText) {
306-
appendOutput(existingContent, outputInfo.id, appendedText, ctx.settings.lineLimit, outputScrolling, false);
303+
// appending output only in scrollable ouputs currently
304+
if (appendedText && outputScrolling) {
305+
appendOutput(existingContent, appendedText, false);
307306
}
308307
else {
309308
const newContent = createContent(outputInfo, ctx, outputScrolling, error);

extensions/notebook-renderers/src/textHelper.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -111,32 +111,8 @@ export function createOutputContent(id: string, outputText: string, linesLimit:
111111
}
112112
}
113113

114-
export function appendOutput(element: HTMLElement, id: string, outputText: string, linesLimit: number, scrollable: boolean, trustHtml: boolean) {
114+
export function appendOutput(element: HTMLElement, outputText: string, trustHtml: boolean) {
115115
const buffer = outputText.split(/\r\n|\r|\n/g);
116-
let newContent: HTMLDivElement;
117-
if (scrollable) {
118-
newContent = scrollableArrayOfString(id, buffer, trustHtml);
119-
element.appendChild(newContent);
120-
// contains 1 span per line
121-
// const innerContainer = element.childNodes[0].childNodes[0];
122-
// const linesToAdd = newContent.childNodes[0].childNodes[0].childNodes;
123-
124-
// linesToAdd.forEach(span => {
125-
// innerContainer.appendChild(span);
126-
// while (innerContainer.childNodes.length > 5000) {
127-
// innerContainer.firstChild?.remove();
128-
// }
129-
// });
130-
} else {
131-
newContent = truncatedArrayOfString(id, buffer, linesLimit, trustHtml);
132-
133-
// contains 1 span per line
134-
const innerContainer = element.childNodes[0].childNodes[0];
135-
const linesToAdd = newContent.childNodes[0].childNodes[0].childNodes;
136-
137-
linesToAdd.forEach(span => {
138-
innerContainer.appendChild(span);
139-
140-
});
141-
}
116+
const newContent = handleANSIOutput(buffer.join('\n'), trustHtml);
117+
element.appendChild(newContent);
142118
}

src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,12 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
14991499
}
15001500

15011501
const outputCache = this.insetMapping.get(content.source)!;
1502+
1503+
if (outputCache.versionId === content.source.model.versionId) {
1504+
// already sent this output version to the renderer
1505+
return;
1506+
}
1507+
15021508
this.hiddenInsetMapping.delete(content.source);
15031509
let updatedContent: ICreationContent | undefined = undefined;
15041510

0 commit comments

Comments
 (0)