diff --git a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx index 91a70cebe4e..26f9ace4e12 100644 --- a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx +++ b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx @@ -442,11 +442,24 @@ export const TextEditor = memo(function TextEditor({ textareaStuckRef.current = true } } - const viewState = - isStreamInteractionLocked && !textareaStuckRef.current ? editor.saveViewState() : null suppressScrollListenerRef.current = true - model.setValue(content) - if (viewState) editor.restoreViewState(viewState) + if (content.startsWith(monacoValue) && monacoValue.length < content.length) { + const lastLine = model.getLineCount() + const lastCol = model.getLineMaxColumn(lastLine) + model.applyEdits([ + { + range: { + startLineNumber: lastLine, + startColumn: lastCol, + endLineNumber: lastLine, + endColumn: lastCol, + }, + text: content.slice(monacoValue.length), + }, + ]) + } else { + model.applyEdits([{ range: model.getFullModelRange(), text: content }]) + } suppressScrollListenerRef.current = false lastSyncedContentRef.current = content }