Skip to content

Commit f68e826

Browse files
authored
Merge pull request #106 from atom-community/dependencies
2 parents 57ea358 + af05d65 commit f68e826

File tree

3 files changed

+905
-658
lines changed

3 files changed

+905
-658
lines changed

lib/datatip-manager.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class DataTipManager {
9393
this.subscriptions.add(
9494
atom.workspace.observeTextEditors((editor) => {
9595
const disposable = this.watchEditor(editor)
96-
editor.onDidDestroy(() => disposable.dispose())
96+
editor.onDidDestroy(() => disposable?.dispose())
9797
}),
9898
atom.commands.add("atom-text-editor", {
9999
"datatip:toggle": (evt) => this.onCommandEvt(evt),
@@ -136,7 +136,6 @@ export class DataTipManager {
136136

137137
/**
138138
* returns the provider registry as a consumable service
139-
* @return {ProviderRegistry<DatatipProvider>} [description]
140139
*/
141140
get datatipService() {
142141
return this.providerRegistry
@@ -184,7 +183,7 @@ export class DataTipManager {
184183
* it has been decided to track this instance
185184
* @param editor the Atom Text editor instance to be tracked
186185
*/
187-
updateCurrentEditor(editor: TextEditor) {
186+
updateCurrentEditor(editor: TextEditor | null) {
188187
if (editor === this.editor) {
189188
return
190189
}
@@ -198,7 +197,7 @@ export class DataTipManager {
198197
this.editor = null
199198
this.editorView = null
200199

201-
if (!atom.workspace.isTextEditor(editor)) {
200+
if (editor == null || !atom.workspace.isTextEditor(editor)) {
202201
return
203202
}
204203

@@ -221,7 +220,7 @@ export class DataTipManager {
221220
this.unmountDataTip()
222221
}),
223222
new Disposable(() => {
224-
this.editorView.removeEventListener("mousemove", this.onMouseMoveEvt)
223+
this.editorView?.removeEventListener("mousemove", this.onMouseMoveEvt)
225224
})
226225
)
227226
}
@@ -243,7 +242,7 @@ export class DataTipManager {
243242
const editor = evt.cursor.editor
244243
const position = evt.cursor.getBufferPosition()
245244
if (this.currentMarkerRange === null || !this.currentMarkerRange.containsPoint(position)) {
246-
this.showDataTip(editor, position, evt)
245+
this.showDataTip(editor, position)
247246
}
248247
},
249248
this.hoverTime,
@@ -261,7 +260,7 @@ export class DataTipManager {
261260

262261
this.mouseMoveTimer = setTimeout(
263262
(evt) => {
264-
if (this.editorView === null) {
263+
if (this.editorView == null || this.editor == null) {
265264
return
266265
}
267266

@@ -280,13 +279,14 @@ export class DataTipManager {
280279
// means the mouse event occured quite far away from where the text ends on that row. Do not
281280
// show the datatip in such situations and hide any existing datatips (the mouse moved more to
282281
// the right, away from the actual text)
282+
// @ts-ignore: internal API
283283
if (distance >= this.editor.getDefaultCharWidth()) {
284284
return this.unmountDataTip()
285285
}
286286

287287
const point = this.editor.bufferPositionForScreenPosition(screenPosition)
288288
if (this.currentMarkerRange === null || !this.currentMarkerRange.containsPoint(point)) {
289-
this.showDataTip(this.editor, point, evt)
289+
this.showDataTip(this.editor, point)
290290
}
291291
},
292292
this.hoverTime,
@@ -306,7 +306,7 @@ export class DataTipManager {
306306
* the central command event handler
307307
* @param evt command event
308308
*/
309-
onCommandEvt(evt: CommandEvent) {
309+
onCommandEvt(evt: CommandEvent<TextEditorElement>) {
310310
const editor = evt.currentTarget.getModel()
311311

312312
if (atom.workspace.isTextEditor(editor)) {
@@ -317,7 +317,7 @@ export class DataTipManager {
317317
return this.unmountDataTip()
318318
}
319319

320-
this.showDataTip(editor, position, undefined)
320+
this.showDataTip(editor, position)
321321
}
322322
}
323323

@@ -331,12 +331,11 @@ export class DataTipManager {
331331
async showDataTip(
332332
editor: TextEditor,
333333
position: Point,
334-
evt: CursorPositionChangedEvent | MouseEvent | null
335334
): Promise<void> {
336335
try {
337336
let datatip: Datatip | null = null
338337
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)
340339
if (providerTip) {
341340
datatip = providerTip
342341
break
@@ -473,19 +472,19 @@ export class DataTipManager {
473472
disposables.add(new Disposable(() => overlayMarker.destroy()))
474473

475474
view.element.addEventListener("mouseenter", () => {
476-
this.editorView.removeEventListener("mousemove", this.onMouseMoveEvt)
475+
this.editorView?.removeEventListener("mousemove", this.onMouseMoveEvt)
477476
})
478477

479478
view.element.addEventListener("mouseleave", () => {
480-
this.editorView.addEventListener("mousemove", this.onMouseMoveEvt)
479+
this.editorView?.addEventListener("mousemove", this.onMouseMoveEvt)
481480
})
482481

483482
// TODO move this code to atom-ide-base
484483
view.element.addEventListener("mousewheel", this.onMouseWheel, { passive: true })
485484

486485
disposables.add(
487486
new Disposable(() => {
488-
this.editorView.addEventListener("mousemove", this.onMouseMoveEvt)
487+
this.editorView?.addEventListener("mousemove", this.onMouseMoveEvt)
489488
view.destroy()
490489
})
491490
)

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@
2828
"busy-signal"
2929
],
3030
"dependencies": {
31-
"atom-package-deps": "^7.1.0",
32-
"atom-ide-base": "^2.1.1"
31+
"atom-ide-base": "^2.1.1",
32+
"atom-package-deps": "^7.1.0"
3333
},
3434
"devDependencies": {
3535
"@types/atom": "^1.40.7",
36-
"@types/node": "^14.14.2",
37-
"atom-languageclient": "^1.0.0",
38-
"@types/jasmine": "^3.5.14",
39-
"atom-jasmine3-test-runner": "^5.1.4",
40-
"typescript": "^4.0.3",
41-
"tslib": "^2.0.3",
42-
"prettier": "^2.1.2",
43-
"eslint": "7.11.0",
44-
"eslint-config-atomic": "^1.5.0",
36+
"@types/jasmine": "^3.6.3",
37+
"@types/node": "^14.14.22",
38+
"atom-jasmine3-test-runner": "^5.1.8",
39+
"atom-languageclient": "^1.0.6",
40+
"build-commit": "^0.1.4",
41+
"cross-env": "latest",
42+
"eslint": "7.18.0",
43+
"eslint-config-atomic": "^1.5.1",
44+
"npm-check-updates": "^11.0.2",
45+
"prettier": "^2.2.1",
4546
"rollup": "^2.38.0",
4647
"rollup-plugin-atomic": "^2.0.1",
47-
"shx": "^0.3.2",
48-
"cross-env": "latest",
49-
"npm-check-updates": "^9.1.2",
50-
"build-commit": "^0.1.1"
48+
"shx": "^0.3.3",
49+
"tslib": "^2.1.0",
50+
"typescript": "^4.1.3"
5151
},
5252
"atomTestRunner": "./spec/runner",
5353
"activationHooks": [

0 commit comments

Comments
 (0)