File tree Expand file tree Collapse file tree
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -442,11 +442,25 @@ export const TextEditor = memo(function TextEditor({
442442 textareaStuckRef . current = true
443443 }
444444 }
445- const viewState =
446- isStreamInteractionLocked && ! textareaStuckRef . current ? editor . saveViewState ( ) : null
447445 suppressScrollListenerRef . current = true
448- model . setValue ( content )
449- if ( viewState ) editor . restoreViewState ( viewState )
446+ const prev = lastSyncedContentRef . current
447+ if ( content . startsWith ( prev ) && prev . length < content . length ) {
448+ const lastLine = model . getLineCount ( )
449+ const lastCol = model . getLineMaxColumn ( lastLine )
450+ model . applyEdits ( [
451+ {
452+ range : {
453+ startLineNumber : lastLine ,
454+ startColumn : lastCol ,
455+ endLineNumber : lastLine ,
456+ endColumn : lastCol ,
457+ } ,
458+ text : content . slice ( prev . length ) ,
459+ } ,
460+ ] )
461+ } else {
462+ model . applyEdits ( [ { range : model . getFullModelRange ( ) , text : content } ] )
463+ }
450464 suppressScrollListenerRef . current = false
451465 lastSyncedContentRef . current = content
452466 }
You can’t perform that action at this time.
0 commit comments