File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
client/modules/IDE/components Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -346,25 +346,23 @@ class Editor extends React.Component {
346346 }
347347 ) ;
348348 this . _cm . doc . setValue ( formatted ) ;
349- return cursorOffset ;
349+ if ( cursorOffset ) {
350+ this . _cm . doc . setCursor ( this . _cm . doc . posFromIndex ( cursorOffset ) ) ;
351+ }
350352 } catch ( error ) {
351- return null ;
353+ console . error ( error ) ;
352354 }
353355 }
354356
355357 tidyCode ( ) {
356358 const mode = this . _cm . getOption ( 'mode' ) ;
357- let cursorOffset ;
358359 if ( mode === 'javascript' ) {
359- cursorOffset = this . prettierFormatWithCursor ( 'babel' , [ babelParser ] ) ;
360+ this . prettierFormatWithCursor ( 'babel' , [ babelParser ] ) ;
360361 } else if ( mode === 'css' ) {
361- cursorOffset = this . prettierFormatWithCursor ( 'css' , [ cssParser ] ) ;
362+ this . prettierFormatWithCursor ( 'css' , [ cssParser ] ) ;
362363 } else if ( mode === 'htmlmixed' ) {
363- cursorOffset = this . prettierFormatWithCursor ( 'html' , [ htmlParser ] ) ;
364+ this . prettierFormatWithCursor ( 'html' , [ htmlParser ] ) ;
364365 }
365- this . _cm . focus ( ) ;
366- if ( cursorOffset )
367- this . _cm . doc . setCursor ( this . _cm . doc . posFromIndex ( cursorOffset ) ) ;
368366 }
369367
370368 initializeDocuments ( files ) {
You can’t perform that action at this time.
0 commit comments