Skip to content

Commit b03c8d5

Browse files
Merge pull request #32 from atom-ide-community/feat/request-token
feat: add request token to markdown service calls
2 parents 58320db + 16876c0 commit b03c8d5

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/datatip-manager.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,15 @@ module.exports = class DatatipManager {
317317
const snippet = m.value.replace(regExpLSPPrefix, '');
318318
return `<pre><code class="${editor.getGrammar().name.toLowerCase()}">${snippet}</code></pre>`;
319319
}).join('\r\n');
320-
this.renderer.render(s).then((html) => {
321-
if (result.range.containsRange(this.currentMarkerRange)) {
320+
const requestToken = `${position.row}:${position.column}`;
321+
this.renderer.render(requestToken, s).then(({ token, html }) => {
322+
if (token == requestToken) { // make sure we are still on the same position
322323
dataTipView = new DataTipView({ htmlView: html });
323324
this.dataTipMarkerDisposables = this.mountDataTipWithMarker(editor, result.range, position, dataTipView);
324325
}
325-
}).catch((err) => {
326+
}).catch(({ token, error }) => {
326327
this.hideDataTip();
327-
console.error(err)
328+
console.error(error);
328329
});
329330
}
330331
});

styles/atom-ide-datatips.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
display: flex;
3535
position: relative;
3636
max-width: 800px;
37+
max-height: 400px;
3738
transition: background-color 0.15s ease;
3839
padding: 8px;
3940
white-space: pre-wrap;

0 commit comments

Comments
 (0)