11'use strict' ;
22
33const alt = require ( '../alt' ) ;
4- const styles = require ( '../../plugins/sidebar/styles' ) ;
54
65const { findNext, findPrevious, replace } = require ( '../actions/find' ) ;
7- const { handleError, handleSuccess } = require ( '../actions/file' ) ;
8- const { handleInput, highlight, syntaxCheck } = require ( '../actions/editor' ) ;
6+ const { handleInput, syntaxCheck } = require ( '../actions/editor' ) ;
97const { moveByScrollUpLine, moveByScrollDownLine } = require ( '../actions/editor-move' ) ;
108const { dedent, indent } = require ( '../actions/text-move' ) ;
119const { print } = require ( '../actions/system' ) ;
@@ -19,7 +17,6 @@ class EditorStore {
1917 onFindPrevious : findPrevious ,
2018 onHandleInput : handleInput ,
2119 onIndent : indent ,
22- onHighlight : highlight ,
2320 onMoveByScrollUpLine : moveByScrollUpLine ,
2421 onMoveByScrollDownLine : moveByScrollDownLine ,
2522 onPrint : print ,
@@ -88,39 +85,29 @@ class EditorStore {
8885 source : workspace . current . deref ( )
8986 } ) ;
9087 if ( result . error ) {
91- this . handleError ( result . error ) ;
92- } else {
93- this . handleSuccess ( 'Tokenization successful!' ) ;
88+ this . _handleError ( result . error ) ;
89+ } else {
90+ this . _handleClear ( ) ;
91+ this . _handleSuccess ( 'Tokenization successful!' ) ;
9492 }
9593 }
96- onHighlight ( opts ) {
97- const { cm } = this . getInstance ( ) ;
98- const doc = cm . getDoc ( ) ;
9994
100- const anchor = doc . posFromIndex ( opts . position ) ;
101- const head = doc . posFromIndex ( opts . position + opts . length ) ;
95+ _handleClear ( ) {
96+ const { toasts } = this . getInstance ( ) ;
10297
103- doc . setSelection ( anchor , head ) ;
98+ toasts . clear ( ) ;
10499 }
105100
101+ _handleError ( err ) {
102+ const { toasts } = this . getInstance ( ) ;
106103
107- //duplicated from file store due to dispatch->dispatch invariant
108- handleError ( err ) {
109- // leaving this in for better debugging of errors
110- console . log ( err ) ;
111- const { toast } = this . getInstance ( ) ;
112-
113- toast . show ( err . message , { style : styles . errorToast } ) ;
114- if ( err && err . errorLength ) {
115- this . onHighlight ( { position : err . errorPosition , length : err . errorLength } ) ;
116- }
104+ toasts . error ( err ) ;
117105 }
118106
119- //duplicated from file store due to dispatch->dispatch invariant
120- handleSuccess ( msg ) {
121- const { toast } = this . getInstance ( ) ;
107+ _handleSuccess ( msg ) {
108+ const { toasts } = this . getInstance ( ) ;
122109
123- toast . show ( msg , { style : styles . successToast , timeout : 5000 } ) ;
110+ toasts . success ( msg ) ;
124111 }
125112}
126113
0 commit comments