@@ -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
@@ -286,7 +285,7 @@ export class DataTipManager {
286
285
287
286
const point = this . editor . bufferPositionForScreenPosition ( screenPosition )
288
287
if ( this . currentMarkerRange === null || ! this . currentMarkerRange . containsPoint ( point ) ) {
289
- this . showDataTip ( this . editor , point , evt )
288
+ this . showDataTip ( this . editor , point )
290
289
}
291
290
} ,
292
291
this . hoverTime ,
@@ -306,7 +305,7 @@ export class DataTipManager {
306
305
* the central command event handler
307
306
* @param evt command event
308
307
*/
309
- onCommandEvt ( evt : CommandEvent ) {
308
+ onCommandEvt ( evt : CommandEvent < TextEditorElement > ) {
310
309
const editor = evt . currentTarget . getModel ( )
311
310
312
311
if ( atom . workspace . isTextEditor ( editor ) ) {
@@ -317,7 +316,7 @@ export class DataTipManager {
317
316
return this . unmountDataTip ( )
318
317
}
319
318
320
- this . showDataTip ( editor , position , undefined )
319
+ this . showDataTip ( editor , position )
321
320
}
322
321
}
323
322
@@ -331,12 +330,11 @@ export class DataTipManager {
331
330
async showDataTip (
332
331
editor : TextEditor ,
333
332
position : Point ,
334
- evt : CursorPositionChangedEvent | MouseEvent | null
335
333
) : Promise < void > {
336
334
try {
337
335
let datatip : Datatip | null = null
338
336
for ( const provider of this . providerRegistry . getAllProvidersForEditor ( editor ) ) {
339
- const providerTip = await provider . datatip ( editor , position , evt )
337
+ const providerTip = await provider . datatip ( editor , position )
340
338
if ( providerTip ) {
341
339
datatip = providerTip
342
340
break
@@ -473,19 +471,19 @@ export class DataTipManager {
473
471
disposables . add ( new Disposable ( ( ) => overlayMarker . destroy ( ) ) )
474
472
475
473
view . element . addEventListener ( "mouseenter" , ( ) => {
476
- this . editorView . removeEventListener ( "mousemove" , this . onMouseMoveEvt )
474
+ this . editorView ? .removeEventListener ( "mousemove" , this . onMouseMoveEvt )
477
475
} )
478
476
479
477
view . element . addEventListener ( "mouseleave" , ( ) => {
480
- this . editorView . addEventListener ( "mousemove" , this . onMouseMoveEvt )
478
+ this . editorView ? .addEventListener ( "mousemove" , this . onMouseMoveEvt )
481
479
} )
482
480
483
481
// TODO move this code to atom-ide-base
484
482
view . element . addEventListener ( "mousewheel" , this . onMouseWheel , { passive : true } )
485
483
486
484
disposables . add (
487
485
new Disposable ( ( ) => {
488
- this . editorView . addEventListener ( "mousemove" , this . onMouseMoveEvt )
486
+ this . editorView ? .addEventListener ( "mousemove" , this . onMouseMoveEvt )
489
487
view . destroy ( )
490
488
} )
491
489
)
0 commit comments