@@ -176,9 +176,7 @@ export class DataTipManager {
176
176
177
177
return new Disposable ( ( ) => {
178
178
disposable . dispose ( )
179
- if ( this . subscriptions != null ) {
180
- this . subscriptions . remove ( disposable )
181
- }
179
+ this . subscriptions . remove ( disposable )
182
180
this . watchedEditors . delete ( editor )
183
181
} )
184
182
}
@@ -202,7 +200,7 @@ export class DataTipManager {
202
200
this . editor = null
203
201
this . editorView = null
204
202
205
- if ( editor == null || ! atom . workspace . isTextEditor ( editor ) ) {
203
+ if ( editor === null || ! atom . workspace . isTextEditor ( editor ) ) {
206
204
return
207
205
}
208
206
@@ -234,7 +232,7 @@ export class DataTipManager {
234
232
* the central cursor movement event handler
235
233
* @param evt the cursor move event
236
234
*/
237
- onCursorMoveEvt ( evt : CursorPositionChangedEvent ) {
235
+ onCursorMoveEvt ( event : CursorPositionChangedEvent ) {
238
236
if ( this . cursorMoveTimer ) {
239
237
clearTimeout ( this . cursorMoveTimer )
240
238
}
@@ -251,21 +249,21 @@ export class DataTipManager {
251
249
}
252
250
} ,
253
251
this . hoverTime ,
254
- evt
252
+ event
255
253
)
256
254
}
257
255
258
256
/**
259
257
* the central mouse movement event handler
260
258
*/
261
- onMouseMoveEvt ( evt : MouseEvent ) {
259
+ onMouseMoveEvt ( event : MouseEvent ) {
262
260
if ( this . mouseMoveTimer ) {
263
261
clearTimeout ( this . mouseMoveTimer )
264
262
}
265
263
266
264
this . mouseMoveTimer = setTimeout (
267
265
( evt ) => {
268
- if ( this . editorView == null || this . editor == null ) {
266
+ if ( this . editorView === null || this . editor = == null ) {
269
267
return
270
268
}
271
269
@@ -284,6 +282,7 @@ export class DataTipManager {
284
282
// means the mouse event occured quite far away from where the text ends on that row. Do not
285
283
// show the datatip in such situations and hide any existing datatips (the mouse moved more to
286
284
// the right, away from the actual text)
285
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
287
286
// @ts -ignore: internal API
288
287
if ( distance >= this . editor . getDefaultCharWidth ( ) ) {
289
288
return this . unmountDataTip ( )
@@ -295,18 +294,10 @@ export class DataTipManager {
295
294
}
296
295
} ,
297
296
this . hoverTime ,
298
- evt
297
+ event
299
298
)
300
299
}
301
300
302
- /**
303
- * handles the mouse wheel event to enable scrolling over long text
304
- * @param evt the mouse wheel event being triggered
305
- */
306
- onMouseWheel ( evt : WheelEvent ) {
307
- evt . stopPropagation ( )
308
- }
309
-
310
301
/**
311
302
* the central command event handler
312
303
* @param evt command event
@@ -337,6 +328,8 @@ export class DataTipManager {
337
328
try {
338
329
let datatip : Datatip | null = null
339
330
for ( const provider of this . providerRegistry . getAllProvidersForEditor ( editor ) ) {
331
+ // we only need one and we want to process them synchronously
332
+ // eslint-disable-next-line no-await-in-loop
340
333
const providerTip = await provider . datatip ( editor , position )
341
334
if ( providerTip ) {
342
335
datatip = providerTip
@@ -347,7 +340,7 @@ export class DataTipManager {
347
340
this . unmountDataTip ( )
348
341
} else {
349
342
// omit update of UI if the range is the same as the current one
350
- if ( this . currentMarkerRange != null && datatip . range . intersectsWith ( this . currentMarkerRange ) ) {
343
+ if ( this . currentMarkerRange !== null && datatip . range . intersectsWith ( this . currentMarkerRange ) ) {
351
344
return
352
345
}
353
346
// make sure we are still on the same position
@@ -448,25 +441,22 @@ export class DataTipManager {
448
441
} )
449
442
450
443
// OPTIMIZATION:
451
- // if there is an overlay already on the same position, skip showing the datatip
444
+ // if there is an highligh overlay already on the same position, skip adding the highlight
452
445
const decorations = editor . getOverlayDecorations ( ) . filter ( ( decoration ) => {
453
- const decorationMarker = decoration . getMarker ( )
454
- if ( decorationMarker . compare ( highlightMarker ) == 1 ) {
455
- return decoration
456
- }
457
- return null
446
+ return decoration . isType ( "highligh" ) && decoration . getMarker ( ) . compare ( highlightMarker ) === 1
458
447
} )
459
448
if ( decorations . length > 0 ) {
460
449
highlightMarker . destroy ( )
461
- return this . dataTipMarkerDisposables
450
+ // END OPTIMIZATION
451
+ } else {
452
+ // Actual Highlighting
453
+ disposables . add ( new Disposable ( ( ) => highlightMarker . destroy ( ) ) )
454
+
455
+ editor . decorateMarker ( highlightMarker , {
456
+ type : "highlight" ,
457
+ class : "datatip-highlight-region" ,
458
+ } )
462
459
}
463
- // END OPTIMIZATION
464
-
465
- disposables . add ( new Disposable ( ( ) => highlightMarker . destroy ( ) ) )
466
- editor . decorateMarker ( highlightMarker , {
467
- type : "highlight" ,
468
- class : "datatip-highlight-region" ,
469
- } )
470
460
471
461
// The actual datatip should appear at the trigger position.
472
462
const overlayMarker = editor . markBufferRange ( new Range ( position , position ) , {
@@ -502,7 +492,7 @@ export class DataTipManager {
502
492
}
503
493
504
494
// TODO move this code to atom-ide-base
505
- element . addEventListener ( "wheel" , this . onMouseWheel , { passive : true } )
495
+ element . addEventListener ( "wheel" , onMouseWheel , { passive : true } )
506
496
507
497
return disposables
508
498
}
@@ -516,3 +506,11 @@ export class DataTipManager {
516
506
this . dataTipMarkerDisposables = null
517
507
}
518
508
}
509
+
510
+ /**
511
+ * handles the mouse wheel event to enable scrolling over long text
512
+ * @param evt the mouse wheel event being triggered
513
+ */
514
+ function onMouseWheel ( evt : WheelEvent ) {
515
+ evt . stopPropagation ( )
516
+ }
0 commit comments