Skip to content

Commit

Permalink
[FurqanSoftware#31] Hover results in continuous server communication …
Browse files Browse the repository at this point in the history
…loop
  • Loading branch information
yblanken committed Oct 22, 2024
1 parent c0f036f commit 4d46cf9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,14 @@ class LanguageServerPlugin implements PluginValue {
): Promise<Tooltip | null> {
if (!this.client.ready || !this.client.capabilities!.hoverProvider) return null;

this.sendChange({ documentText: view.state.doc.toString() });
const result = await this.client.textDocumentHover({
textDocument: { uri: this.documentUri },
position: { line, character },
});
if (!result) return null;
const { contents, range } = result;
let formattedContents = formatContents(contents)
if (formattedContents.length == 0) return null;
let pos = posToOffset(view.state.doc, { line, character })!;
let end: number;
if (range) {
Expand All @@ -328,8 +329,8 @@ class LanguageServerPlugin implements PluginValue {
if (pos === null) return null;
const dom = document.createElement('div');
dom.classList.add('documentation');
if (this.allowHTMLContent) dom.innerHTML = formatContents(contents);
else dom.textContent = formatContents(contents);
if (this.allowHTMLContent) dom.innerHTML = formattedContents;
else dom.textContent = formattedContents;
return { pos, end, create: (view) => ({ dom }), above: true };
}

Expand Down

0 comments on commit 4d46cf9

Please sign in to comment.