@@ -87,19 +87,19 @@ function date(dateFormat) {
87
87
return str . length == 1 ? "0" + str : str ;
88
88
}
89
89
90
- var SnippetManager = function ( ) {
91
- this . snippetMap = { } ;
92
- this . snippetNameMap = { } ;
93
- } ;
90
+ class SnippetManager {
91
+ constructor ( ) {
92
+ this . snippetMap = { } ;
93
+ this . snippetNameMap = { } ;
94
+ this . variables = VARIABLES ;
95
+ }
94
96
95
- ( function ( ) {
96
- oop . implement ( this , EventEmitter ) ;
97
97
98
- this . getTokenizer = function ( ) {
98
+ getTokenizer ( ) {
99
99
return SnippetManager . $tokenizer || this . createTokenizer ( ) ;
100
- } ;
100
+ }
101
101
102
- this . createTokenizer = function ( ) {
102
+ createTokenizer ( ) {
103
103
function TabstopToken ( str ) {
104
104
str = str . substr ( 1 ) ;
105
105
if ( / ^ \d + $ / . test ( str ) )
@@ -218,15 +218,15 @@ var SnippetManager = function() {
218
218
]
219
219
} ) ;
220
220
return SnippetManager . $tokenizer ;
221
- } ;
221
+ }
222
222
223
- this . tokenizeTmSnippet = function ( str , startState ) {
223
+ tokenizeTmSnippet ( str , startState ) {
224
224
return this . getTokenizer ( ) . getLineTokens ( str , startState ) . tokens . map ( function ( x ) {
225
225
return x . value || x ;
226
226
} ) ;
227
- } ;
227
+ }
228
228
229
- this . getVariableValue = function ( editor , name , indentation ) {
229
+ getVariableValue ( editor , name , indentation ) {
230
230
if ( / ^ \d + $ / . test ( name ) )
231
231
return ( this . variables . __ || { } ) [ name ] || "" ;
232
232
if ( / ^ [ A - Z ] \d + $ / . test ( name ) )
@@ -239,12 +239,10 @@ var SnippetManager = function() {
239
239
if ( typeof value == "function" )
240
240
value = this . variables [ name ] ( editor , name , indentation ) ;
241
241
return value == null ? "" : value ;
242
- } ;
242
+ }
243
243
244
- this . variables = VARIABLES ;
245
-
246
244
// returns string formatted according to http://manual.macromates.com/en/regular_expressions#replacement_string_syntax_format_strings
247
- this . tmStrFormat = function ( str , ch , editor ) {
245
+ tmStrFormat ( str , ch , editor ) {
248
246
if ( ! ch . fmt ) return str ;
249
247
var flag = ch . flag || "" ;
250
248
var re = ch . guard ;
@@ -282,17 +280,17 @@ var SnippetManager = function() {
282
280
return fmtParts . join ( "" ) ;
283
281
} ) ;
284
282
return formatted ;
285
- } ;
283
+ }
286
284
287
- this . tmFormatFunction = function ( str , ch , editor ) {
285
+ tmFormatFunction ( str , ch , editor ) {
288
286
if ( ch . formatFunction == "upcase" )
289
287
return str . toUpperCase ( ) ;
290
288
if ( ch . formatFunction == "downcase" )
291
289
return str . toLowerCase ( ) ;
292
290
return str ;
293
- } ;
291
+ }
294
292
295
- this . resolveVariables = function ( snippet , editor ) {
293
+ resolveVariables ( snippet , editor ) {
296
294
var result = [ ] ;
297
295
var indentation = "" ;
298
296
var afterNewLine = true ;
@@ -347,139 +345,14 @@ var SnippetManager = function() {
347
345
i = i1 ;
348
346
}
349
347
return result ;
350
- } ;
351
-
352
- var processSnippetText = function ( editor , snippetText , options = { } ) {
353
- var cursor = editor . getCursorPosition ( ) ;
354
- var line = editor . session . getLine ( cursor . row ) ;
355
- var tabString = editor . session . getTabString ( ) ;
356
- var indentString = line . match ( / ^ \s * / ) [ 0 ] ;
357
-
358
- if ( cursor . column < indentString . length )
359
- indentString = indentString . slice ( 0 , cursor . column ) ;
348
+ }
360
349
361
- snippetText = snippetText . replace ( / \r / g, "" ) ;
362
- var tokens = this . tokenizeTmSnippet ( snippetText ) ;
363
- tokens = this . resolveVariables ( tokens , editor ) ;
364
- // indent
365
- tokens = tokens . map ( function ( x ) {
366
- if ( x == "\n" && ! options . excludeExtraIndent )
367
- return x + indentString ;
368
- if ( typeof x == "string" )
369
- return x . replace ( / \t / g, tabString ) ;
370
- return x ;
371
- } ) ;
372
- // tabstop values
373
- var tabstops = [ ] ;
374
- tokens . forEach ( function ( p , i ) {
375
- if ( typeof p != "object" )
376
- return ;
377
- var id = p . tabstopId ;
378
- var ts = tabstops [ id ] ;
379
- if ( ! ts ) {
380
- ts = tabstops [ id ] = [ ] ;
381
- ts . index = id ;
382
- ts . value = "" ;
383
- ts . parents = { } ;
384
- }
385
- if ( ts . indexOf ( p ) !== - 1 )
386
- return ;
387
- if ( p . choices && ! ts . choices )
388
- ts . choices = p . choices ;
389
- ts . push ( p ) ;
390
- var i1 = tokens . indexOf ( p , i + 1 ) ;
391
- if ( i1 === - 1 )
392
- return ;
393
-
394
- var value = tokens . slice ( i + 1 , i1 ) ;
395
- var isNested = value . some ( function ( t ) { return typeof t === "object" ; } ) ;
396
- if ( isNested && ! ts . value ) {
397
- ts . value = value ;
398
- } else if ( value . length && ( ! ts . value || typeof ts . value !== "string" ) ) {
399
- ts . value = value . join ( "" ) ;
400
- }
401
- } ) ;
402
-
403
- // expand tabstop values
404
- tabstops . forEach ( function ( ts ) { ts . length = 0 ; } ) ;
405
- var expanding = { } ;
406
- function copyValue ( val ) {
407
- var copy = [ ] ;
408
- for ( var i = 0 ; i < val . length ; i ++ ) {
409
- var p = val [ i ] ;
410
- if ( typeof p == "object" ) {
411
- if ( expanding [ p . tabstopId ] )
412
- continue ;
413
- var j = val . lastIndexOf ( p , i - 1 ) ;
414
- p = copy [ j ] || { tabstopId : p . tabstopId } ;
415
- }
416
- copy [ i ] = p ;
417
- }
418
- return copy ;
419
- }
420
- for ( var i = 0 ; i < tokens . length ; i ++ ) {
421
- var p = tokens [ i ] ;
422
- if ( typeof p != "object" )
423
- continue ;
424
- var id = p . tabstopId ;
425
- var ts = tabstops [ id ] ;
426
- var i1 = tokens . indexOf ( p , i + 1 ) ;
427
- if ( expanding [ id ] ) {
428
- // if reached closing bracket clear expanding state
429
- if ( expanding [ id ] === p ) {
430
- delete expanding [ id ] ;
431
- Object . keys ( expanding ) . forEach ( function ( parentId ) {
432
- ts . parents [ parentId ] = true ;
433
- } ) ;
434
- }
435
- // otherwise just ignore recursive tabstop
436
- continue ;
437
- }
438
- expanding [ id ] = p ;
439
- var value = ts . value ;
440
- if ( typeof value !== "string" )
441
- value = copyValue ( value ) ;
442
- else if ( p . fmt )
443
- value = this . tmStrFormat ( value , p , editor ) ;
444
- tokens . splice . apply ( tokens , [ i + 1 , Math . max ( 0 , i1 - i ) ] . concat ( value , p ) ) ;
445
-
446
- if ( ts . indexOf ( p ) === - 1 )
447
- ts . push ( p ) ;
448
- }
449
-
450
- // convert to plain text
451
- var row = 0 , column = 0 ;
452
- var text = "" ;
453
- tokens . forEach ( function ( t ) {
454
- if ( typeof t === "string" ) {
455
- var lines = t . split ( "\n" ) ;
456
- if ( lines . length > 1 ) {
457
- column = lines [ lines . length - 1 ] . length ;
458
- row += lines . length - 1 ;
459
- } else
460
- column += t . length ;
461
- text += t ;
462
- } else if ( t ) {
463
- if ( ! t . start )
464
- t . start = { row : row , column : column } ;
465
- else
466
- t . end = { row : row , column : column } ;
467
- }
468
- } ) ;
469
-
470
- return {
471
- text,
472
- tabstops,
473
- tokens
474
- } ;
475
- } ;
476
-
477
- this . getDisplayTextForSnippet = function ( editor , snippetText ) {
350
+ getDisplayTextForSnippet ( editor , snippetText ) {
478
351
var processedSnippet = processSnippetText . call ( this , editor , snippetText ) ;
479
352
return processedSnippet . text ;
480
- } ;
353
+ }
481
354
482
- this . insertSnippetForSelection = function ( editor , snippetText , options = { } ) {
355
+ insertSnippetForSelection ( editor , snippetText , options = { } ) {
483
356
var processedSnippet = processSnippetText . call ( this , editor , snippetText , options ) ;
484
357
485
358
var range = editor . getSelectionRange ( ) ;
@@ -491,9 +364,9 @@ var SnippetManager = function() {
491
364
var tabstopManager = new TabstopManager ( editor ) ;
492
365
var selectionId = editor . inVirtualSelectionMode && editor . selection . index ;
493
366
tabstopManager . addTabstops ( processedSnippet . tabstops , range . start , end , selectionId ) ;
494
- } ;
367
+ }
495
368
496
- this . insertSnippet = function ( editor , snippetText , options = { } ) {
369
+ insertSnippet ( editor , snippetText , options = { } ) {
497
370
var self = this ;
498
371
if ( options . range && ! ( options . range instanceof Range ) )
499
372
options . range = Range . fromPoints ( options . range . start , options . range . end ) ;
@@ -507,9 +380,9 @@ var SnippetManager = function() {
507
380
508
381
if ( editor . tabstopManager )
509
382
editor . tabstopManager . tabNext ( ) ;
510
- } ;
383
+ }
511
384
512
- this . $getScope = function ( editor ) {
385
+ $getScope ( editor ) {
513
386
var scope = editor . session . $mode . $id || "" ;
514
387
scope = scope . split ( "/" ) . pop ( ) ;
515
388
if ( scope === "html" || scope === "php" ) {
@@ -532,9 +405,9 @@ var SnippetManager = function() {
532
405
}
533
406
534
407
return scope ;
535
- } ;
408
+ }
536
409
537
- this . getActiveScopes = function ( editor ) {
410
+ getActiveScopes ( editor ) {
538
411
var scope = this . $getScope ( editor ) ;
539
412
var scopes = [ scope ] ;
540
413
var snippetMap = this . snippetMap ;
@@ -543,19 +416,19 @@ var SnippetManager = function() {
543
416
}
544
417
scopes . push ( "_" ) ;
545
418
return scopes ;
546
- } ;
419
+ }
547
420
548
- this . expandWithTab = function ( editor , options ) {
421
+ expandWithTab ( editor , options ) {
549
422
var self = this ;
550
423
var result = editor . forEachSelection ( function ( ) {
551
424
return self . expandSnippetForSelection ( editor , options ) ;
552
425
} , null , { keepOrder : true } ) ;
553
426
if ( result && editor . tabstopManager )
554
427
editor . tabstopManager . tabNext ( ) ;
555
428
return result ;
556
- } ;
429
+ }
557
430
558
- this . expandSnippetForSelection = function ( editor , options ) {
431
+ expandSnippetForSelection ( editor , options ) {
559
432
var cursor = editor . getCursorPosition ( ) ;
560
433
var line = editor . session . getLine ( cursor . row ) ;
561
434
var before = line . substring ( 0 , cursor . column ) ;
@@ -584,9 +457,9 @@ var SnippetManager = function() {
584
457
585
458
this . variables . M__ = this . variables . T__ = null ;
586
459
return true ;
587
- } ;
460
+ }
588
461
589
- this . findMatchingSnippet = function ( snippetList , before , after ) {
462
+ findMatchingSnippet ( snippetList , before , after ) {
590
463
for ( var i = snippetList . length ; i -- ; ) {
591
464
var s = snippetList [ i ] ;
592
465
if ( s . startRe && ! s . startRe . test ( before ) )
@@ -602,11 +475,9 @@ var SnippetManager = function() {
602
475
s . replaceAfter = s . endTriggerRe ? s . endTriggerRe . exec ( after ) [ 0 ] : "" ;
603
476
return s ;
604
477
}
605
- } ;
478
+ }
606
479
607
- this . snippetMap = { } ;
608
- this . snippetNameMap = { } ;
609
- this . register = function ( snippets , scope ) {
480
+ register ( snippets , scope ) {
610
481
var snippetMap = this . snippetMap ;
611
482
var snippetNameMap = this . snippetNameMap ;
612
483
var self = this ;
@@ -684,8 +555,8 @@ var SnippetManager = function() {
684
555
}
685
556
686
557
this . _signal ( "registerSnippets" , { scope : scope } ) ;
687
- } ;
688
- this . unregister = function ( snippets , scope ) {
558
+ }
559
+ unregister ( snippets , scope ) {
689
560
var snippetMap = this . snippetMap ;
690
561
var snippetNameMap = this . snippetNameMap ;
691
562
@@ -703,8 +574,8 @@ var SnippetManager = function() {
703
574
removeSnippet ( snippets ) ;
704
575
else if ( Array . isArray ( snippets ) )
705
576
snippets . forEach ( removeSnippet ) ;
706
- } ;
707
- this . parseSnippetFile = function ( str ) {
577
+ }
578
+ parseSnippetFile ( str ) {
708
579
str = str . replace ( / \r / g, "" ) ;
709
580
var list = [ ] , snippet = { } ;
710
581
var re = / ^ # .* | ^ ( { [ \s \S ] * } ) \s * $ | ^ ( \S + ) ( .* ) $ | ^ ( (?: \n * \t .* ) + ) / gm;
@@ -737,8 +608,8 @@ var SnippetManager = function() {
737
608
}
738
609
}
739
610
return list ;
740
- } ;
741
- this . getSnippetByName = function ( name , editor ) {
611
+ }
612
+ getSnippetByName ( name , editor ) {
742
613
var snippetMap = this . snippetNameMap ;
743
614
var snippet ;
744
615
this . getActiveScopes ( editor ) . some ( function ( scope ) {
@@ -748,55 +619,183 @@ var SnippetManager = function() {
748
619
return ! ! snippet ;
749
620
} , this ) ;
750
621
return snippet ;
751
- } ;
622
+ }
623
+ }
752
624
753
- } ) . call ( SnippetManager . prototype ) ;
625
+ oop . implement ( SnippetManager . prototype , EventEmitter ) ;
754
626
627
+ var processSnippetText = function ( editor , snippetText , options = { } ) {
628
+ var cursor = editor . getCursorPosition ( ) ;
629
+ var line = editor . session . getLine ( cursor . row ) ;
630
+ var tabString = editor . session . getTabString ( ) ;
631
+ var indentString = line . match ( / ^ \s * / ) [ 0 ] ;
632
+
633
+ if ( cursor . column < indentString . length )
634
+ indentString = indentString . slice ( 0 , cursor . column ) ;
635
+
636
+ snippetText = snippetText . replace ( / \r / g, "" ) ;
637
+ var tokens = this . tokenizeTmSnippet ( snippetText ) ;
638
+ tokens = this . resolveVariables ( tokens , editor ) ;
639
+ // indent
640
+ tokens = tokens . map ( function ( x ) {
641
+ if ( x == "\n" && ! options . excludeExtraIndent )
642
+ return x + indentString ;
643
+ if ( typeof x == "string" )
644
+ return x . replace ( / \t / g, tabString ) ;
645
+ return x ;
646
+ } ) ;
647
+ // tabstop values
648
+ var tabstops = [ ] ;
649
+ tokens . forEach ( function ( p , i ) {
650
+ if ( typeof p != "object" )
651
+ return ;
652
+ var id = p . tabstopId ;
653
+ var ts = tabstops [ id ] ;
654
+ if ( ! ts ) {
655
+ ts = tabstops [ id ] = [ ] ;
656
+ ts . index = id ;
657
+ ts . value = "" ;
658
+ ts . parents = { } ;
659
+ }
660
+ if ( ts . indexOf ( p ) !== - 1 )
661
+ return ;
662
+ if ( p . choices && ! ts . choices )
663
+ ts . choices = p . choices ;
664
+ ts . push ( p ) ;
665
+ var i1 = tokens . indexOf ( p , i + 1 ) ;
666
+ if ( i1 === - 1 )
667
+ return ;
668
+
669
+ var value = tokens . slice ( i + 1 , i1 ) ;
670
+ var isNested = value . some ( function ( t ) { return typeof t === "object" ; } ) ;
671
+ if ( isNested && ! ts . value ) {
672
+ ts . value = value ;
673
+ } else if ( value . length && ( ! ts . value || typeof ts . value !== "string" ) ) {
674
+ ts . value = value . join ( "" ) ;
675
+ }
676
+ } ) ;
677
+
678
+ // expand tabstop values
679
+ tabstops . forEach ( function ( ts ) { ts . length = 0 ; } ) ;
680
+ var expanding = { } ;
681
+ function copyValue ( val ) {
682
+ var copy = [ ] ;
683
+ for ( var i = 0 ; i < val . length ; i ++ ) {
684
+ var p = val [ i ] ;
685
+ if ( typeof p == "object" ) {
686
+ if ( expanding [ p . tabstopId ] )
687
+ continue ;
688
+ var j = val . lastIndexOf ( p , i - 1 ) ;
689
+ p = copy [ j ] || { tabstopId : p . tabstopId } ;
690
+ }
691
+ copy [ i ] = p ;
692
+ }
693
+ return copy ;
694
+ }
695
+ for ( var i = 0 ; i < tokens . length ; i ++ ) {
696
+ var p = tokens [ i ] ;
697
+ if ( typeof p != "object" )
698
+ continue ;
699
+ var id = p . tabstopId ;
700
+ var ts = tabstops [ id ] ;
701
+ var i1 = tokens . indexOf ( p , i + 1 ) ;
702
+ if ( expanding [ id ] ) {
703
+ // if reached closing bracket clear expanding state
704
+ if ( expanding [ id ] === p ) {
705
+ delete expanding [ id ] ;
706
+ Object . keys ( expanding ) . forEach ( function ( parentId ) {
707
+ ts . parents [ parentId ] = true ;
708
+ } ) ;
709
+ }
710
+ // otherwise just ignore recursive tabstop
711
+ continue ;
712
+ }
713
+ expanding [ id ] = p ;
714
+ var value = ts . value ;
715
+ if ( typeof value !== "string" )
716
+ value = copyValue ( value ) ;
717
+ else if ( p . fmt )
718
+ value = this . tmStrFormat ( value , p , editor ) ;
719
+ tokens . splice . apply ( tokens , [ i + 1 , Math . max ( 0 , i1 - i ) ] . concat ( value , p ) ) ;
720
+
721
+ if ( ts . indexOf ( p ) === - 1 )
722
+ ts . push ( p ) ;
723
+ }
724
+
725
+ // convert to plain text
726
+ var row = 0 , column = 0 ;
727
+ var text = "" ;
728
+ tokens . forEach ( function ( t ) {
729
+ if ( typeof t === "string" ) {
730
+ var lines = t . split ( "\n" ) ;
731
+ if ( lines . length > 1 ) {
732
+ column = lines [ lines . length - 1 ] . length ;
733
+ row += lines . length - 1 ;
734
+ } else
735
+ column += t . length ;
736
+ text += t ;
737
+ } else if ( t ) {
738
+ if ( ! t . start )
739
+ t . start = { row : row , column : column } ;
740
+ else
741
+ t . end = { row : row , column : column } ;
742
+ }
743
+ } ) ;
755
744
756
- var TabstopManager = function ( editor ) {
757
- if ( editor . tabstopManager )
758
- return editor . tabstopManager ;
759
- editor . tabstopManager = this ;
760
- this . $onChange = this . onChange . bind ( this ) ;
761
- this . $onChangeSelection = lang . delayedCall ( this . onChangeSelection . bind ( this ) ) . schedule ;
762
- this . $onChangeSession = this . onChangeSession . bind ( this ) ;
763
- this . $onAfterExec = this . onAfterExec . bind ( this ) ;
764
- this . attach ( editor ) ;
745
+ return {
746
+ text,
747
+ tabstops,
748
+ tokens
749
+ } ;
765
750
} ;
766
- ( function ( ) {
767
- this . attach = function ( editor ) {
751
+
752
+ class TabstopManager {
753
+ constructor ( editor ) {
768
754
this . index = 0 ;
769
755
this . ranges = [ ] ;
770
756
this . tabstops = [ ] ;
757
+ if ( editor . tabstopManager )
758
+ return editor . tabstopManager ;
759
+ editor . tabstopManager = this ;
760
+ this . $onChange = this . onChange . bind ( this ) ;
761
+ this . $onChangeSelection = lang . delayedCall ( this . onChangeSelection . bind ( this ) ) . schedule ;
762
+ this . $onChangeSession = this . onChangeSession . bind ( this ) ;
763
+ this . $onAfterExec = this . onAfterExec . bind ( this ) ;
764
+ this . attach ( editor ) ;
765
+ }
766
+
767
+ attach ( editor ) {
771
768
this . $openTabstops = null ;
772
769
this . selectedTabstop = null ;
773
770
774
771
this . editor = editor ;
772
+ this . session = editor . session ;
775
773
this . editor . on ( "change" , this . $onChange ) ;
776
774
this . editor . on ( "changeSelection" , this . $onChangeSelection ) ;
777
775
this . editor . on ( "changeSession" , this . $onChangeSession ) ;
778
776
this . editor . commands . on ( "afterExec" , this . $onAfterExec ) ;
779
777
this . editor . keyBinding . addKeyboardHandler ( this . keyboardHandler ) ;
780
- } ;
781
- this . detach = function ( ) {
778
+ }
779
+ detach ( ) {
782
780
this . tabstops . forEach ( this . removeTabstopMarkers , this ) ;
783
- this . ranges = null ;
784
- this . tabstops = null ;
781
+ this . ranges . length = 0 ;
782
+ this . tabstops . length = 0 ;
785
783
this . selectedTabstop = null ;
786
- this . editor . removeListener ( "change" , this . $onChange ) ;
787
- this . editor . removeListener ( "changeSelection" , this . $onChangeSelection ) ;
788
- this . editor . removeListener ( "changeSession" , this . $onChangeSession ) ;
789
- this . editor . commands . removeListener ( "afterExec" , this . $onAfterExec ) ;
784
+ this . editor . off ( "change" , this . $onChange ) ;
785
+ this . editor . off ( "changeSelection" , this . $onChangeSelection ) ;
786
+ this . editor . off ( "changeSession" , this . $onChangeSession ) ;
787
+ this . editor . commands . off ( "afterExec" , this . $onAfterExec ) ;
790
788
this . editor . keyBinding . removeKeyboardHandler ( this . keyboardHandler ) ;
791
789
this . editor . tabstopManager = null ;
790
+ this . session = null ;
792
791
this . editor = null ;
793
- } ;
792
+ }
794
793
795
- this . onChange = function ( delta ) {
794
+ onChange ( delta ) {
796
795
var isRemove = delta . action [ 0 ] == "r" ;
797
796
var selectedTabstop = this . selectedTabstop || { } ;
798
797
var parents = selectedTabstop . parents || { } ;
799
- var tabstops = ( this . tabstops || [ ] ) . slice ( ) ;
798
+ var tabstops = this . tabstops . slice ( ) ;
800
799
for ( var i = 0 ; i < tabstops . length ; i ++ ) {
801
800
var ts = tabstops [ i ] ;
802
801
var active = ts == selectedTabstop || parents [ ts . index ] ;
@@ -814,16 +813,16 @@ var TabstopManager = function(editor) {
814
813
}
815
814
ts . rangeList . $onChange ( delta ) ;
816
815
}
817
- var session = this . editor . session ;
816
+ var session = this . session ;
818
817
if ( ! this . $inChange && isRemove && session . getLength ( ) == 1 && ! session . getValue ( ) )
819
818
this . detach ( ) ;
820
- } ;
821
- this . updateLinkedFields = function ( ) {
819
+ }
820
+ updateLinkedFields ( ) {
822
821
var ts = this . selectedTabstop ;
823
822
if ( ! ts || ! ts . hasLinkedRanges || ! ts . firstNonLinked )
824
823
return ;
825
824
this . $inChange = true ;
826
- var session = this . editor . session ;
825
+ var session = this . session ;
827
826
var text = session . getTextRange ( ts . firstNonLinked ) ;
828
827
for ( var i = 0 ; i < ts . length ; i ++ ) {
829
828
var range = ts [ i ] ;
@@ -834,12 +833,12 @@ var TabstopManager = function(editor) {
834
833
session . replace ( range , fmt ) ;
835
834
}
836
835
this . $inChange = false ;
837
- } ;
838
- this . onAfterExec = function ( e ) {
836
+ }
837
+ onAfterExec ( e ) {
839
838
if ( e . command && ! e . command . readOnly )
840
839
this . updateLinkedFields ( ) ;
841
- } ;
842
- this . onChangeSelection = function ( ) {
840
+ }
841
+ onChangeSelection ( ) {
843
842
if ( ! this . editor )
844
843
return ;
845
844
var lead = this . editor . selection . lead ;
@@ -854,11 +853,11 @@ var TabstopManager = function(editor) {
854
853
return ;
855
854
}
856
855
this . detach ( ) ;
857
- } ;
858
- this . onChangeSession = function ( ) {
856
+ }
857
+ onChangeSession ( ) {
859
858
this . detach ( ) ;
860
- } ;
861
- this . tabNext = function ( dir ) {
859
+ }
860
+ tabNext ( dir ) {
862
861
var max = this . tabstops . length ;
863
862
var index = this . index + ( dir || 1 ) ;
864
863
index = Math . min ( Math . max ( index , 1 ) , max ) ;
@@ -867,8 +866,8 @@ var TabstopManager = function(editor) {
867
866
this . selectTabstop ( index ) ;
868
867
if ( index === 0 )
869
868
this . detach ( ) ;
870
- } ;
871
- this . selectTabstop = function ( index ) {
869
+ }
870
+ selectTabstop ( index ) {
872
871
this . $openTabstops = null ;
873
872
var ts = this . tabstops [ this . index ] ;
874
873
if ( ts )
@@ -896,8 +895,8 @@ var TabstopManager = function(editor) {
896
895
this . editor . keyBinding . addKeyboardHandler ( this . keyboardHandler ) ;
897
896
if ( this . selectedTabstop && this . selectedTabstop . choices )
898
897
this . editor . execCommand ( "startAutocomplete" , { matches : this . selectedTabstop . choices } ) ;
899
- } ;
900
- this . addTabstops = function ( tabstops , start , end ) {
898
+ }
899
+ addTabstops ( tabstops , start , end ) {
901
900
var useLink = this . useLink || ! this . editor . getOption ( "enableMultiselect" ) ;
902
901
903
902
if ( ! this . $openTabstops )
@@ -953,57 +952,57 @@ var TabstopManager = function(editor) {
953
952
arg . push ( arg . splice ( 2 , 1 ) [ 0 ] ) ;
954
953
this . tabstops . splice . apply ( this . tabstops , arg ) ;
955
954
}
956
- } ;
955
+ }
957
956
958
- this . addTabstopMarkers = function ( ts ) {
959
- var session = this . editor . session ;
957
+ addTabstopMarkers ( ts ) {
958
+ var session = this . session ;
960
959
ts . forEach ( function ( range ) {
961
960
if ( ! range . markerId )
962
961
range . markerId = session . addMarker ( range , "ace_snippet-marker" , "text" ) ;
963
962
} ) ;
964
- } ;
965
- this . removeTabstopMarkers = function ( ts ) {
966
- var session = this . editor . session ;
963
+ }
964
+ removeTabstopMarkers ( ts ) {
965
+ var session = this . session ;
967
966
ts . forEach ( function ( range ) {
968
967
session . removeMarker ( range . markerId ) ;
969
968
range . markerId = null ;
970
969
} ) ;
971
- } ;
972
- this . removeRange = function ( range ) {
970
+ }
971
+ removeRange ( range ) {
973
972
var i = range . tabstop . indexOf ( range ) ;
974
973
if ( i != - 1 ) range . tabstop . splice ( i , 1 ) ;
975
974
i = this . ranges . indexOf ( range ) ;
976
975
if ( i != - 1 ) this . ranges . splice ( i , 1 ) ;
977
976
i = range . tabstop . rangeList . ranges . indexOf ( range ) ;
978
977
if ( i != - 1 ) range . tabstop . splice ( i , 1 ) ;
979
- this . editor . session . removeMarker ( range . markerId ) ;
978
+ this . session . removeMarker ( range . markerId ) ;
980
979
if ( ! range . tabstop . length ) {
981
980
i = this . tabstops . indexOf ( range . tabstop ) ;
982
981
if ( i != - 1 )
983
982
this . tabstops . splice ( i , 1 ) ;
984
983
if ( ! this . tabstops . length )
985
984
this . detach ( ) ;
986
985
}
987
- } ;
986
+ }
987
+ }
988
988
989
- this . keyboardHandler = new HashHandler ( ) ;
990
- this . keyboardHandler . bindKeys ( {
991
- "Tab" : function ( editor ) {
992
- if ( exports . snippetManager && exports . snippetManager . expandWithTab ( editor ) )
993
- return ;
994
- editor . tabstopManager . tabNext ( 1 ) ;
995
- editor . renderer . scrollCursorIntoView ( ) ;
996
- } ,
997
- "Shift-Tab" : function ( editor ) {
998
- editor . tabstopManager . tabNext ( - 1 ) ;
999
- editor . renderer . scrollCursorIntoView ( ) ;
1000
- } ,
1001
- "Esc" : function ( editor ) {
1002
- editor . tabstopManager . detach ( ) ;
1003
- }
1004
- } ) ;
1005
- } ) . call ( TabstopManager . prototype ) ;
1006
989
990
+ TabstopManager . prototype . keyboardHandler = new HashHandler ( ) ;
991
+ TabstopManager . prototype . keyboardHandler . bindKeys ( {
992
+ "Tab" : function ( editor ) {
993
+ if ( exports . snippetManager && exports . snippetManager . expandWithTab ( editor ) )
994
+ return ;
995
+ editor . tabstopManager . tabNext ( 1 ) ;
996
+ editor . renderer . scrollCursorIntoView ( ) ;
997
+ } ,
998
+ "Shift-Tab" : function ( editor ) {
999
+ editor . tabstopManager . tabNext ( - 1 ) ;
1000
+ editor . renderer . scrollCursorIntoView ( ) ;
1001
+ } ,
1002
+ "Esc" : function ( editor ) {
1003
+ editor . tabstopManager . detach ( ) ;
1004
+ }
1005
+ } ) ;
1007
1006
1008
1007
1009
1008
var movePoint = function ( point , diff ) {
0 commit comments