@@ -232,6 +232,7 @@ export default class Editor {
232
232
this . statusLength = this . statusBar . find ( '.status-length' )
233
233
this . statusTheme = this . statusBar . find ( '.status-theme' )
234
234
this . statusSpellcheck = this . statusBar . find ( '.status-spellcheck' )
235
+ this . statusLinter = this . statusBar . find ( '.status-linter' )
235
236
this . statusPreferences = this . statusBar . find ( '.status-preferences' )
236
237
this . statusPanel = this . editor . addPanel ( this . statusBar [ 0 ] , {
237
238
position : 'bottom'
@@ -241,6 +242,7 @@ export default class Editor {
241
242
this . setKeymap ( )
242
243
this . setTheme ( )
243
244
this . setSpellcheck ( )
245
+ this . setLinter ( )
244
246
this . setPreferences ( )
245
247
}
246
248
@@ -499,6 +501,42 @@ export default class Editor {
499
501
}
500
502
}
501
503
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
+
502
540
resetEditorKeymapToBrowserKeymap ( ) {
503
541
var keymap = this . editor . getOption ( 'keyMap' )
504
542
if ( ! this . jumpToAddressBarKeymapValue ) {
@@ -553,7 +591,6 @@ export default class Editor {
553
591
this . editor = CodeMirror . fromTextArea ( textit , {
554
592
mode : defaultEditorMode ,
555
593
backdrop : defaultEditorMode ,
556
- lint : true ,
557
594
keyMap : 'sublime' ,
558
595
viewportMargin : viewportMargin ,
559
596
styleActiveLine : true ,
@@ -573,7 +610,6 @@ export default class Editor {
573
610
autoCloseTags : true ,
574
611
foldGutter : true ,
575
612
gutters : [
576
- 'CodeMirror-lint-markers' ,
577
613
'CodeMirror-linenumbers' ,
578
614
'authorship-gutters' ,
579
615
'CodeMirror-foldgutter'
0 commit comments