Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit dd72b82

Browse files
committed
Do not display empty string hover/datatips
1 parent 0744a25 commit dd72b82

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/adapters/datatip-adapter.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as atomIde from 'atom-ide';
22
import Convert from '../convert';
33
import Utils from '../utils';
44
import {
5+
Hover,
56
LanguageClientConnection,
67
MarkupContent,
78
MarkedString,
@@ -43,12 +44,7 @@ export default class DatatipAdapter {
4344
const documentPositionParams = Convert.editorToTextDocumentPositionParams(editor, point);
4445

4546
const hover = await connection.hover(documentPositionParams);
46-
if (
47-
hover == null ||
48-
hover.contents == null ||
49-
(typeof hover.contents === 'string' && hover.contents.length === 0) ||
50-
(Array.isArray(hover.contents) && hover.contents.length === 0)
51-
) {
47+
if (hover == null || DatatipAdapter.isEmptyHover(hover)) {
5248
return null;
5349
}
5450

@@ -62,6 +58,13 @@ export default class DatatipAdapter {
6258
return { range, markedStrings };
6359
}
6460

61+
private static isEmptyHover(hover: Hover): boolean {
62+
return hover.contents == null ||
63+
(typeof hover.contents === 'string' && hover.contents.length === 0) ||
64+
(Array.isArray(hover.contents) &&
65+
(hover.contents.length === 0 || hover.contents[0] === ""));
66+
}
67+
6568
private static convertMarkedString(
6669
editor: TextEditor,
6770
markedString: MarkedString | MarkupContent,

0 commit comments

Comments
 (0)