diff --git a/lib/atom-ternjs-documentation.js b/lib/atom-ternjs-documentation.js index 9f53f36..6ae437a 100644 --- a/lib/atom-ternjs-documentation.js +++ b/lib/atom-ternjs-documentation.js @@ -74,50 +74,35 @@ class Documentation { }); }) .catch((err) => { - + err && debug.handleReject(err.type, err.message); }); } show() { - if (!this.marker) { - - let editor = atom.workspace.getActiveTextEditor(); - let cursor = editor.getLastCursor(); - - if (!editor || !cursor) { - - return; - } + const editor = atom.workspace.getActiveTextEditor(); - this.marker = cursor.getMarker(); + if (!editor) { - if (!this.marker) { + return; + } - return; - } + const marker = editor.getLastCursor && editor.getLastCursor().getMarker(); - this.overlayDecoration = editor.decorateMarker(this.marker, { + if (!marker) { - type: 'overlay', - item: this.view, - class: 'atom-ternjs-documentation', - position: 'tale', - invalidate: 'touch' - }); - - } else { + return; + } - this.marker.setProperties({ + this.overlayDecoration = editor.decorateMarker(marker, { - type: 'overlay', - item: this.view, - class: 'atom-ternjs-documentation', - position: 'tale', - invalidate: 'touch' - }); - } + type: 'overlay', + item: this.view, + class: 'atom-ternjs-documentation', + position: 'tale', + invalidate: 'touch' + }); } destroyOverlay() { @@ -128,7 +113,6 @@ class Documentation { } this.overlayDecoration = null; - this.marker = null; } destroy() { diff --git a/lib/atom-ternjs-type.js b/lib/atom-ternjs-type.js index c7ddb55..2ee872b 100644 --- a/lib/atom-ternjs-type.js +++ b/lib/atom-ternjs-type.js @@ -20,7 +20,6 @@ class Type { this.view = undefined; this.overlayDecoration = undefined; - this.marker = undefined; this.view = new TypeView(); this.view.initialize(this); @@ -34,42 +33,28 @@ class Type { setPosition() { - if (!this.marker) { + const editor = atom.workspace.getActiveTextEditor(); - const editor = atom.workspace.getActiveTextEditor(); + if (!editor) { - if (!editor) { - - return; - } - - this.marker = editor.getLastCursor && editor.getLastCursor().getMarker(); - - if (!this.marker) { + return; + } - return; - } + const marker = editor.getLastCursor && editor.getLastCursor().getMarker(); - this.overlayDecoration = editor.decorateMarker(this.marker, { + if (!marker) { - type: 'overlay', - item: this.view, - class: 'atom-ternjs-type', - position: 'tale', - invalidate: 'touch' - }); - - } else { + return; + } - this.marker.setProperties({ + this.overlayDecoration = editor.decorateMarker(marker, { - type: 'overlay', - item: this.view, - class: 'atom-ternjs-type', - position: 'tale', - invalidate: 'touch' - }); - } + type: 'overlay', + item: this.view, + class: 'atom-ternjs-type', + position: 'tale', + invalidate: 'touch' + }); } queryType(editor, cursor) { @@ -267,13 +252,12 @@ class Type { destroyOverlay() { - this.marker = undefined; - if (this.overlayDecoration) { this.overlayDecoration.destroy(); - this.overlayDecoration = undefined; } + + this.overlayDecoration = null; } }