Skip to content

Commit e68a34f

Browse files
committed
append when stream outputs are concatenated
1 parent 5b78562 commit e68a34f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

extensions/notebook-renderers/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,17 @@ function renderStream(outputInfo: OutputWithAppend, outputElement: HTMLElement,
282282
const previousOutputParent = getPreviousMatchingContentGroup(outputElement);
283283
// If the previous output item for the same cell was also a stream, append this output to the previous
284284
if (previousOutputParent) {
285-
const newContent = createContent(outputInfo, ctx, outputScrolling, error);
286285
const existingContent = previousOutputParent.querySelector(`[output-item-id="${outputInfo.id}"]`) as HTMLElement | null;
287286
if (existingContent) {
288-
existingContent.replaceWith(newContent);
289-
287+
if (appendedText && outputScrolling) {
288+
appendScrollableOutput(existingContent, outputInfo.id, appendedText, outputInfo.text(), false);
289+
}
290+
else {
291+
const newContent = createContent(outputInfo, ctx, outputScrolling, error);
292+
existingContent.replaceWith(newContent);
293+
}
290294
} else {
295+
const newContent = createContent(outputInfo, ctx, outputScrolling, error);
291296
previousOutputParent.appendChild(newContent);
292297
}
293298
previousOutputParent.classList.toggle('scrollbar-visible', previousOutputParent.scrollHeight > previousOutputParent.clientHeight);

extensions/notebook-renderers/src/textHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function appendScrollableOutput(element: HTMLElement, id: string, appende
128128
outputLengths[id] = Math.min(fullBuffer.length, softScrollableLineLimit);
129129
const newElement = scrollableArrayOfString(id, fullBuffer.slice(-1 * softScrollableLineLimit), trustHtml);
130130
newElement.setAttribute('output-item-id', id);
131-
element.replaceWith();
131+
element.replaceWith(newElement);
132132
}
133133
else {
134134
element.appendChild(handleANSIOutput(buffer.join('\n'), trustHtml));

0 commit comments

Comments
 (0)