append when stream outputs are concatenated

This commit is contained in:
Aaron Munger 2023-07-12 15:20:43 -07:00
parent 5b78562d6c
commit e68a34f9bd
2 changed files with 9 additions and 4 deletions

View file

@ -282,12 +282,17 @@ function renderStream(outputInfo: OutputWithAppend, outputElement: HTMLElement,
const previousOutputParent = getPreviousMatchingContentGroup(outputElement);
// If the previous output item for the same cell was also a stream, append this output to the previous
if (previousOutputParent) {
const newContent = createContent(outputInfo, ctx, outputScrolling, error);
const existingContent = previousOutputParent.querySelector(`[output-item-id="${outputInfo.id}"]`) as HTMLElement | null;
if (existingContent) {
existingContent.replaceWith(newContent);
if (appendedText && outputScrolling) {
appendScrollableOutput(existingContent, outputInfo.id, appendedText, outputInfo.text(), false);
}
else {
const newContent = createContent(outputInfo, ctx, outputScrolling, error);
existingContent.replaceWith(newContent);
}
} else {
const newContent = createContent(outputInfo, ctx, outputScrolling, error);
previousOutputParent.appendChild(newContent);
}
previousOutputParent.classList.toggle('scrollbar-visible', previousOutputParent.scrollHeight > previousOutputParent.clientHeight);

View file

@ -128,7 +128,7 @@ export function appendScrollableOutput(element: HTMLElement, id: string, appende
outputLengths[id] = Math.min(fullBuffer.length, softScrollableLineLimit);
const newElement = scrollableArrayOfString(id, fullBuffer.slice(-1 * softScrollableLineLimit), trustHtml);
newElement.setAttribute('output-item-id', id);
element.replaceWith();
element.replaceWith(newElement);
}
else {
element.appendChild(handleANSIOutput(buffer.join('\n'), trustHtml));