@@ -93,7 +93,7 @@ export class DataTipManager {
93
93
this . subscriptions . add (
94
94
atom . workspace . observeTextEditors ( ( editor ) => {
95
95
const disposable = this . watchEditor ( editor )
96
- editor . onDidDestroy ( ( ) => disposable . dispose ( ) )
96
+ editor . onDidDestroy ( ( ) => disposable ? .dispose ( ) )
97
97
} ) ,
98
98
atom . commands . add ( "atom-text-editor" , {
99
99
"datatip:toggle" : ( evt ) => this . onCommandEvt ( evt ) ,
@@ -136,7 +136,6 @@ export class DataTipManager {
136
136
137
137
/**
138
138
* returns the provider registry as a consumable service
139
- * @return {ProviderRegistry<DatatipProvider> } [description]
140
139
*/
141
140
get datatipService ( ) {
142
141
return this . providerRegistry
@@ -184,7 +183,7 @@ export class DataTipManager {
184
183
* it has been decided to track this instance
185
184
* @param editor the Atom Text editor instance to be tracked
186
185
*/
187
- updateCurrentEditor ( editor : TextEditor ) {
186
+ updateCurrentEditor ( editor : TextEditor | null ) {
188
187
if ( editor === this . editor ) {
189
188
return
190
189
}
@@ -198,7 +197,7 @@ export class DataTipManager {
198
197
this . editor = null
199
198
this . editorView = null
200
199
201
- if ( ! atom . workspace . isTextEditor ( editor ) ) {
200
+ if ( editor == null || ! atom . workspace . isTextEditor ( editor ) ) {
202
201
return
203
202
}
204
203
@@ -221,7 +220,7 @@ export class DataTipManager {
221
220
this . unmountDataTip ( )
222
221
} ) ,
223
222
new Disposable ( ( ) => {
224
- this . editorView . removeEventListener ( "mousemove" , this . onMouseMoveEvt )
223
+ this . editorView ? .removeEventListener ( "mousemove" , this . onMouseMoveEvt )
225
224
} )
226
225
)
227
226
}
@@ -243,7 +242,7 @@ export class DataTipManager {
243
242
const editor = evt . cursor . editor
244
243
const position = evt . cursor . getBufferPosition ( )
245
244
if ( this . currentMarkerRange === null || ! this . currentMarkerRange . containsPoint ( position ) ) {
246
- this . showDataTip ( editor , position , evt )
245
+ this . showDataTip ( editor , position )
247
246
}
248
247
} ,
249
248
this . hoverTime ,
@@ -261,7 +260,7 @@ export class DataTipManager {
261
260
262
261
this . mouseMoveTimer = setTimeout (
263
262
( evt ) => {
264
- if ( this . editorView === null ) {
263
+ if ( this . editorView == null || this . editor = = null ) {
265
264
return
266
265
}
267
266
@@ -280,13 +279,14 @@ export class DataTipManager {
280
279
// means the mouse event occured quite far away from where the text ends on that row. Do not
281
280
// show the datatip in such situations and hide any existing datatips (the mouse moved more to
282
281
// the right, away from the actual text)
282
+ // @ts -ignore: internal API
283
283
if ( distance >= this . editor . getDefaultCharWidth ( ) ) {
284
284
return this . unmountDataTip ( )
285
285
}
286
286
287
287
const point = this . editor . bufferPositionForScreenPosition ( screenPosition )
288
288
if ( this . currentMarkerRange === null || ! this . currentMarkerRange . containsPoint ( point ) ) {
289
- this . showDataTip ( this . editor , point , evt )
289
+ this . showDataTip ( this . editor , point )
290
290
}
291
291
} ,
292
292
this . hoverTime ,
@@ -306,7 +306,7 @@ export class DataTipManager {
306
306
* the central command event handler
307
307
* @param evt command event
308
308
*/
309
- onCommandEvt ( evt : CommandEvent ) {
309
+ onCommandEvt ( evt : CommandEvent < TextEditorElement > ) {
310
310
const editor = evt . currentTarget . getModel ( )
311
311
312
312
if ( atom . workspace . isTextEditor ( editor ) ) {
@@ -317,7 +317,7 @@ export class DataTipManager {
317
317
return this . unmountDataTip ( )
318
318
}
319
319
320
- this . showDataTip ( editor , position , undefined )
320
+ this . showDataTip ( editor , position )
321
321
}
322
322
}
323
323
@@ -331,12 +331,11 @@ export class DataTipManager {
331
331
async showDataTip (
332
332
editor : TextEditor ,
333
333
position : Point ,
334
- evt : CursorPositionChangedEvent | MouseEvent | null
335
334
) : Promise < void > {
336
335
try {
337
336
let datatip : Datatip | null = null
338
337
for ( const provider of this . providerRegistry . getAllProvidersForEditor ( editor ) ) {
339
- const providerTip = await provider . datatip ( editor , position , evt )
338
+ const providerTip = await provider . datatip ( editor , position )
340
339
if ( providerTip ) {
341
340
datatip = providerTip
342
341
break
@@ -473,19 +472,19 @@ export class DataTipManager {
473
472
disposables . add ( new Disposable ( ( ) => overlayMarker . destroy ( ) ) )
474
473
475
474
view . element . addEventListener ( "mouseenter" , ( ) => {
476
- this . editorView . removeEventListener ( "mousemove" , this . onMouseMoveEvt )
475
+ this . editorView ? .removeEventListener ( "mousemove" , this . onMouseMoveEvt )
477
476
} )
478
477
479
478
view . element . addEventListener ( "mouseleave" , ( ) => {
480
- this . editorView . addEventListener ( "mousemove" , this . onMouseMoveEvt )
479
+ this . editorView ? .addEventListener ( "mousemove" , this . onMouseMoveEvt )
481
480
} )
482
481
483
482
// TODO move this code to atom-ide-base
484
483
view . element . addEventListener ( "mousewheel" , this . onMouseWheel , { passive : true } )
485
484
486
485
disposables . add (
487
486
new Disposable ( ( ) => {
488
- this . editorView . addEventListener ( "mousemove" , this . onMouseMoveEvt )
487
+ this . editorView ? .addEventListener ( "mousemove" , this . onMouseMoveEvt )
489
488
view . destroy ( )
490
489
} )
491
490
)
0 commit comments