@@ -34,7 +34,7 @@ class GutterKeyboardHandler {
34
34
e . preventDefault ( ) ;
35
35
36
36
if ( e . keyCode === keys [ "escape" ] )
37
- this . annotationTooltip . hide ( ) ;
37
+ this . annotationTooltip . hideTooltip ( ) ;
38
38
39
39
return ;
40
40
}
@@ -88,6 +88,16 @@ class GutterKeyboardHandler {
88
88
}
89
89
90
90
// After here, foucs is on a gutter icon and we want to interact with them.
91
+ this . $handleGutterKeyboardInteraction ( e ) ;
92
+
93
+ // Wait until folding is completed and then signal gutterkeydown to the editor.
94
+ setTimeout ( function ( ) {
95
+ // Signal to the editor that a key is pressed inside the gutter.
96
+ this . editor . _signal ( "gutterkeydown" , new GutterKeyboardEvent ( e , this ) ) ;
97
+ } . bind ( this ) , 10 ) ;
98
+ }
99
+
100
+ $handleGutterKeyboardInteraction ( e ) {
91
101
// Prevent tabbing when interacting with the gutter icons.
92
102
if ( e . keyCode === keys [ "tab" ] ) {
93
103
e . preventDefault ( ) ;
@@ -137,12 +147,14 @@ class GutterKeyboardHandler {
137
147
if ( e . keyCode === keys [ "left" ] ) {
138
148
e . preventDefault ( ) ;
139
149
this . $switchLane ( "annotation" ) ;
150
+ return ;
140
151
}
141
152
142
153
// Try to switch from annotations to fold widgets.
143
154
if ( e . keyCode === keys [ "right" ] ) {
144
155
e . preventDefault ( ) ;
145
156
this . $switchLane ( "fold" ) ;
157
+ return ;
146
158
}
147
159
148
160
if ( e . keyCode === keys [ "enter" ] || e . keyCode === keys [ "space" ] ) {
@@ -198,7 +210,7 @@ class GutterKeyboardHandler {
198
210
}
199
211
200
212
if ( this . annotationTooltip . isOpen )
201
- this . annotationTooltip . hide ( ) ;
213
+ this . annotationTooltip . hideTooltip ( ) ;
202
214
203
215
return ;
204
216
}
@@ -288,7 +300,6 @@ class GutterKeyboardHandler {
288
300
var annotation = this . $getAnnotation ( index ) ;
289
301
290
302
annotation . classList . add ( this . editor . renderer . keyboardFocusClassName ) ;
291
- annotation . setAttribute ( "role" , "button" ) ;
292
303
annotation . focus ( ) ;
293
304
}
294
305
@@ -303,7 +314,6 @@ class GutterKeyboardHandler {
303
314
var annotation = this . $getAnnotation ( index ) ;
304
315
305
316
annotation . classList . remove ( this . editor . renderer . keyboardFocusClassName ) ;
306
- annotation . removeAttribute ( "role" ) ;
307
317
annotation . blur ( ) ;
308
318
}
309
319
@@ -423,4 +433,52 @@ class GutterKeyboardHandler {
423
433
}
424
434
}
425
435
426
- exports . GutterKeyboardHandler = GutterKeyboardHandler ;
436
+ exports . GutterKeyboardHandler = GutterKeyboardHandler ;
437
+
438
+ /*
439
+ * Custom Ace gutter keyboard event
440
+ */
441
+ class GutterKeyboardEvent {
442
+ constructor ( domEvent , gutterKeyboardHandler ) {
443
+ this . gutterKeyboardHandler = gutterKeyboardHandler ;
444
+ this . domEvent = domEvent ;
445
+ }
446
+
447
+ /**
448
+ * Returns the key that was presssed.
449
+ *
450
+ * @return {string } the key that was pressed.
451
+ */
452
+ getKey ( ) {
453
+ return keys . keyCodeToString ( this . domEvent . keyCode ) ;
454
+ }
455
+
456
+ /**
457
+ * Returns the row in the gutter that was focused after the keyboard event was handled.
458
+ *
459
+ * @return {number } the key that was pressed.
460
+ */
461
+ getRow ( ) {
462
+ return this . gutterKeyboardHandler . $rowIndexToRow ( this . gutterKeyboardHandler . activeRowIndex ) ;
463
+ }
464
+
465
+ /**
466
+ * Returns whether focus is on the annotation lane after the keyboard event was handled.
467
+ *
468
+ * @return {boolean } true if focus was on the annotation lane after the keyboard event.
469
+ */
470
+ isInAnnotationLane ( ) {
471
+ return this . gutterKeyboardHandler . activeLane === "annotation" ;
472
+ }
473
+
474
+ /**
475
+ * Returns whether focus is on the fold lane after the keyboard event was handled.
476
+ *
477
+ * @return {boolean } true if focus was on the fold lane after the keyboard event.
478
+ */
479
+ isInFoldLane ( ) {
480
+ return this . gutterKeyboardHandler . activeLane === "fold" ;
481
+ }
482
+ }
483
+
484
+ exports . GutterKeyboardEvent = GutterKeyboardEvent ;
0 commit comments