Skip to content

Commit 377f209

Browse files
authored
Merge pull request #164 from krassowski/fix/signature
Correctly display documentation of signature returned as MarkupContent
2 parents f7ddb22 + 220b093 commit 377f209

File tree

3 files changed

+41
-24
lines changed

3 files changed

+41
-24
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
- fixed various small bugs in the completer (
1515
[#162](https://github.com/krassowski/jupyterlab-lsp/pull/162)
1616
)
17+
- fix documentation display in signature for LSP servers which
18+
return MarkupContent (
19+
[#164](https://github.com/krassowski/jupyterlab-lsp/pull/164)
20+
)
1721

1822
## `lsp-ws-connection 0.3.1`
1923

atest/05_Features/Signature.robot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*** Settings ***
2-
Suite Setup Setup Suite For Screenshots completion
2+
Suite Setup Setup Suite For Screenshots signature
3+
Force Tags feature:signature
34
Resource ../Keywords.robot
45

56
*** Variables ***

packages/jupyterlab-lsp/src/adapters/codemirror/features/signature.ts

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,44 @@ export class Signature extends CodeMirrorLSPFeature {
4242
let markdown = '```' + language + '\n' + item.label + '\n```';
4343
if (item.documentation) {
4444
markdown += '\n';
45-
46-
let in_text_block = false;
47-
// TODO: make use of the MarkupContent object instead
48-
for (let line of item.documentation.toString().split('\n')) {
49-
if (line.trim() === item.label.trim()) {
50-
continue;
51-
}
52-
53-
if (line.startsWith('>>>')) {
54-
if (in_text_block) {
55-
markdown += '```\n\n';
56-
in_text_block = false;
45+
if (
46+
typeof item.documentation === 'string' ||
47+
item.documentation.kind === 'plaintext'
48+
) {
49+
let in_text_block = false;
50+
// TODO: make use of the MarkupContent object instead
51+
for (let line of item.documentation.toString().split('\n')) {
52+
if (line.trim() === item.label.trim()) {
53+
continue;
5754
}
58-
line = '```' + language + '\n' + line.substr(3) + '\n```';
59-
} else {
60-
// start new text block
61-
if (!in_text_block) {
62-
markdown += '```\n';
63-
in_text_block = true;
55+
56+
if (line.startsWith('>>>')) {
57+
if (in_text_block) {
58+
markdown += '```\n\n';
59+
in_text_block = false;
60+
}
61+
line = '```' + language + '\n' + line.substr(3) + '\n```';
62+
} else {
63+
// start new text block
64+
if (!in_text_block) {
65+
markdown += '```\n';
66+
in_text_block = true;
67+
}
6468
}
69+
markdown += line + '\n';
6570
}
66-
markdown += line + '\n';
67-
}
68-
// close off the text block - if any
69-
if (in_text_block) {
70-
markdown += '```';
71+
// close off the text block - if any
72+
if (in_text_block) {
73+
markdown += '```';
74+
}
75+
} else {
76+
if (item.documentation.kind !== 'markdown') {
77+
this.virtual_editor.console.warn(
78+
'Unknown MarkupContent kind:',
79+
item.documentation.kind
80+
);
81+
}
82+
markdown += item.documentation.value;
7183
}
7284
}
7385
return markdown;

0 commit comments

Comments
 (0)