Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit 6630cf9

Browse files
authored
fix: handle invalid hover responses by displaying errors (#47)
1 parent d7fa415 commit 6630cf9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/hoverifier.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,16 @@ export const createHoverifier = ({
485485
}
486486
// Fetch the hover for that position
487487
const hoverFetch = fetchHover(position).pipe(
488+
// Some language servers don't conform to the LSP specification
489+
// (e.g. Python LS sometimes returns an empty object). For the
490+
// convenience of consumers of codeintellify, we'll handle this
491+
// here.
492+
map(
493+
hoverMergedOrNull =>
494+
hoverMergedOrNull === null || HoverMerged.is(hoverMergedOrNull)
495+
? hoverMergedOrNull
496+
: new Error(`Invalid hover response: ${JSON.stringify(hoverMergedOrNull)}`)
497+
),
488498
catchError(error => {
489499
if (error && error.code === EMODENOTFOUND) {
490500
return [null]

0 commit comments

Comments
 (0)