File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 299299 }
300300
301301 loadText ( ) {
302- this . editor . value = localStorage . getItem ( SHIRO_SAVED_TEXT ) || '' ;
303- this . loadCursorPosition ( ) ;
304- this . updateCount ( ) ;
302+ // Hide editor until text is loaded to prevent flickering
303+ const editor = this . editor ;
304+ editor . style . visibility = 'hidden' ;
305+ editor . value = localStorage . getItem ( SHIRO_SAVED_TEXT ) || '' ;
306+ requestAnimationFrame ( ( ) => {
307+ this . loadCursorPosition ( ) ;
308+ editor . style . visibility = 'visible' ;
309+ this . updateCount ( ) ;
310+ } ) ;
305311 }
306312
307313 saveCursorPosition ( ) {
313319 if ( saved ) {
314320 const position = parseInt ( saved ) ;
315321 const editor = this . editor ;
316- setTimeout ( ( ) => {
322+ requestAnimationFrame ( ( ) => {
317323 editor . setSelectionRange ( position , position ) ;
318324 editor . focus ( { preventScroll : true } ) ;
319325
320326 // Fix scroll jumping when cursor is on the first line
321327 const lineNumber = editor . value . substring ( 0 , position ) . split ( '\n' ) . length - 1 ;
322328 if ( lineNumber === 0 ) editor . scrollTop = 0 ;
323-
324- } , 0 ) ;
329+ } ) ;
325330 }
326331 }
327332
You can’t perform that action at this time.
0 commit comments