From 48263251f59667f49f1cea652ba84f8879b6e854 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Thu, 26 Sep 2024 10:02:16 +0200 Subject: [PATCH] Improve notebook output stream initialization --- javascript/src/ycell.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/javascript/src/ycell.ts b/javascript/src/ycell.ts index 4bee750..6c033df 100644 --- a/javascript/src/ycell.ts +++ b/javascript/src/ycell.ts @@ -793,12 +793,13 @@ export class YCodeCell const { text, ...outputWithoutText } = output; _newOutput1 = outputWithoutText; const newText = new Y.Text(); - let length = 0; - // text is a list of strings - for (const str of text as string[]) { - newText.insert(length, str); - length += str.length; + let _text: string; + if (text instanceof Array) { + _text = text.join(); + } else { + _text = text as string; } + newText.insert(0, _text); _newOutput1['text'] = newText; } else { _newOutput1 = output;