@@ -232,6 +232,7 @@ export default class Editor {
232232 this . statusLength = this . statusBar . find ( '.status-length' )
233233 this . statusTheme = this . statusBar . find ( '.status-theme' )
234234 this . statusSpellcheck = this . statusBar . find ( '.status-spellcheck' )
235+ this . statusLinter = this . statusBar . find ( '.status-linter' )
235236 this . statusPreferences = this . statusBar . find ( '.status-preferences' )
236237 this . statusPanel = this . editor . addPanel ( this . statusBar [ 0 ] , {
237238 position : 'bottom'
@@ -241,6 +242,7 @@ export default class Editor {
241242 this . setKeymap ( )
242243 this . setTheme ( )
243244 this . setSpellcheck ( )
245+ this . setLinter ( )
244246 this . setPreferences ( )
245247 }
246248
@@ -499,6 +501,42 @@ export default class Editor {
499501 }
500502 }
501503
504+ toggleLinter ( enable ) {
505+ const gutters = this . editor . getOption ( 'gutters' )
506+ const lintGutter = 'CodeMirror-lint-markers'
507+
508+ if ( enable ) {
509+ if ( ! gutters . includes ( lintGutter ) ) {
510+ this . editor . setOption ( 'gutters' , [ lintGutter , ...gutters ] )
511+ }
512+ Cookies . set ( 'linter' , true , {
513+ expires : 365
514+ } )
515+ } else {
516+ this . editor . setOption ( 'gutters' , gutters . filter ( g => g !== lintGutter ) )
517+ Cookies . remove ( 'linter' )
518+ }
519+ this . editor . setOption ( 'lint' , enable )
520+ }
521+
522+ setLinter ( ) {
523+ const linterToggle = this . statusLinter . find ( '.ui-linter-toggle' )
524+
525+ const updateLinterStatus = ( enable ) => {
526+ linterToggle . toggleClass ( 'active' , enable )
527+ }
528+
529+ linterToggle . click ( ( ) => {
530+ const lintEnable = this . editor . getOption ( 'lint' )
531+ this . toggleLinter . bind ( this ) ( ! lintEnable )
532+ updateLinterStatus ( ! lintEnable )
533+ } )
534+
535+ const enable = ! ! Cookies . get ( 'linter' )
536+ this . toggleLinter . bind ( this ) ( enable )
537+ updateLinterStatus ( enable )
538+ }
539+
502540 resetEditorKeymapToBrowserKeymap ( ) {
503541 var keymap = this . editor . getOption ( 'keyMap' )
504542 if ( ! this . jumpToAddressBarKeymapValue ) {
@@ -553,7 +591,6 @@ export default class Editor {
553591 this . editor = CodeMirror . fromTextArea ( textit , {
554592 mode : defaultEditorMode ,
555593 backdrop : defaultEditorMode ,
556- lint : true ,
557594 keyMap : 'sublime' ,
558595 viewportMargin : viewportMargin ,
559596 styleActiveLine : true ,
@@ -573,7 +610,6 @@ export default class Editor {
573610 autoCloseTags : true ,
574611 foldGutter : true ,
575612 gutters : [
576- 'CodeMirror-lint-markers' ,
577613 'CodeMirror-linenumbers' ,
578614 'authorship-gutters' ,
579615 'CodeMirror-foldgutter'
0 commit comments