@@ -176,9 +176,7 @@ export class DataTipManager {
176176
177177 return new Disposable ( ( ) => {
178178 disposable . dispose ( )
179- if ( this . subscriptions != null ) {
180- this . subscriptions . remove ( disposable )
181- }
179+ this . subscriptions . remove ( disposable )
182180 this . watchedEditors . delete ( editor )
183181 } )
184182 }
@@ -202,7 +200,7 @@ export class DataTipManager {
202200 this . editor = null
203201 this . editorView = null
204202
205- if ( editor == null || ! atom . workspace . isTextEditor ( editor ) ) {
203+ if ( editor === null || ! atom . workspace . isTextEditor ( editor ) ) {
206204 return
207205 }
208206
@@ -234,7 +232,7 @@ export class DataTipManager {
234232 * the central cursor movement event handler
235233 * @param evt the cursor move event
236234 */
237- onCursorMoveEvt ( evt : CursorPositionChangedEvent ) {
235+ onCursorMoveEvt ( event : CursorPositionChangedEvent ) {
238236 if ( this . cursorMoveTimer ) {
239237 clearTimeout ( this . cursorMoveTimer )
240238 }
@@ -251,21 +249,21 @@ export class DataTipManager {
251249 }
252250 } ,
253251 this . hoverTime ,
254- evt
252+ event
255253 )
256254 }
257255
258256 /**
259257 * the central mouse movement event handler
260258 */
261- onMouseMoveEvt ( evt : MouseEvent ) {
259+ onMouseMoveEvt ( event : MouseEvent ) {
262260 if ( this . mouseMoveTimer ) {
263261 clearTimeout ( this . mouseMoveTimer )
264262 }
265263
266264 this . mouseMoveTimer = setTimeout (
267265 ( evt ) => {
268- if ( this . editorView == null || this . editor == null ) {
266+ if ( this . editorView === null || this . editor = == null ) {
269267 return
270268 }
271269
@@ -284,6 +282,7 @@ export class DataTipManager {
284282 // means the mouse event occured quite far away from where the text ends on that row. Do not
285283 // show the datatip in such situations and hide any existing datatips (the mouse moved more to
286284 // the right, away from the actual text)
285+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
287286 // @ts -ignore: internal API
288287 if ( distance >= this . editor . getDefaultCharWidth ( ) ) {
289288 return this . unmountDataTip ( )
@@ -295,18 +294,10 @@ export class DataTipManager {
295294 }
296295 } ,
297296 this . hoverTime ,
298- evt
297+ event
299298 )
300299 }
301300
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-
310301 /**
311302 * the central command event handler
312303 * @param evt command event
@@ -337,6 +328,8 @@ export class DataTipManager {
337328 try {
338329 let datatip : Datatip | null = null
339330 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
340333 const providerTip = await provider . datatip ( editor , position )
341334 if ( providerTip ) {
342335 datatip = providerTip
@@ -347,7 +340,7 @@ export class DataTipManager {
347340 this . unmountDataTip ( )
348341 } else {
349342 // 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 ) ) {
351344 return
352345 }
353346 // make sure we are still on the same position
@@ -448,25 +441,22 @@ export class DataTipManager {
448441 } )
449442
450443 // 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
452445 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
458447 } )
459448 if ( decorations . length > 0 ) {
460449 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+ } )
462459 }
463- // END OPTIMIZATION
464-
465- disposables . add ( new Disposable ( ( ) => highlightMarker . destroy ( ) ) )
466- editor . decorateMarker ( highlightMarker , {
467- type : "highlight" ,
468- class : "datatip-highlight-region" ,
469- } )
470460
471461 // The actual datatip should appear at the trigger position.
472462 const overlayMarker = editor . markBufferRange ( new Range ( position , position ) , {
@@ -502,7 +492,7 @@ export class DataTipManager {
502492 }
503493
504494 // TODO move this code to atom-ide-base
505- element . addEventListener ( "wheel" , this . onMouseWheel , { passive : true } )
495+ element . addEventListener ( "wheel" , onMouseWheel , { passive : true } )
506496
507497 return disposables
508498 }
@@ -516,3 +506,11 @@ export class DataTipManager {
516506 this . dataTipMarkerDisposables = null
517507 }
518508}
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