diff --git a/src/index.ts b/src/index.ts index fc82d28..aba3286 100644 --- a/src/index.ts +++ b/src/index.ts @@ -312,13 +312,14 @@ class LanguageServerPlugin implements PluginValue { ): Promise { 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) { @@ -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 }; }