Skip to content

Commit 6bd8831

Browse files
authored
Merge pull request #391 from krassowski/fix-388-do-not-hint-if-only-match-same-as-token
Fix continuous hinting showing up when it has nothing to offer
2 parents 6b868d2 + e6095cd commit 6bd8831

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
- custom cell syntax highlighting is now properly removed when no longer needed ([#387])
88
- the completer in continuous hinting now works well with the pasted text ([#389])
9+
- continuous hinting suggestions will no longer show up if the only hint is the same as the current token ([#391])
910

1011
[#387]: https://github.com/krassowski/jupyterlab-lsp/issues/387
1112
[#389]: https://github.com/krassowski/jupyterlab-lsp/issues/389
13+
[#391]: https://github.com/krassowski/jupyterlab-lsp/issues/391
1214

1315
### `@krassowski/jupyterlab-lsp 2.0.7` (2020-09-18)
1416

atest/05_Features/Completion.robot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ Works In File Editor
4747
Completer Should Suggest add
4848
[Teardown] Clean Up After Working With File completion.py
4949

50+
Continious Hinting Works
51+
Configure JupyterLab Plugin {"continuousHinting": true} plugin id=${COMPLETION PLUGIN ID}
52+
Prepare File for Editing Python completion completion.py
53+
Place Cursor In File Editor At 9 2
54+
Capture Page Screenshot 01-editor-ready.png
55+
Press Keys None d
56+
Completer Should Suggest addition
57+
5058
Autocompletes If Only One Option
5159
Enter Cell Editor 3 line=1
5260
Press Keys None cle

packages/jupyterlab-lsp/src/features/completion/completion_handler.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export class LSPConnector
205205
}
206206

207207
return promise.then(reply => {
208-
reply = this.suppress_if_needed(reply);
208+
reply = this.suppress_if_needed(reply, token);
209209
this.trigger_kind = CompletionTriggerKind.Invoked;
210210
return reply;
211211
});
@@ -413,9 +413,17 @@ export class LSPConnector
413413
return Promise.resolve(undefined);
414414
}
415415

416-
private suppress_if_needed(reply: CompletionHandler.ICompletionItemsReply) {
416+
private suppress_if_needed(
417+
reply: CompletionHandler.ICompletionItemsReply,
418+
token: CodeEditor.IToken
419+
) {
417420
if (this.trigger_kind == AdditionalCompletionTriggerKinds.AutoInvoked) {
418-
if (reply.start == reply.end) {
421+
if (
422+
// do not auto-invoke if no match found
423+
reply.start == reply.end ||
424+
// do not auto-invoke if only one match found and this match is exactly the same as the current token
425+
(reply.items.length === 1 && reply.items[0].insertText === token.value)
426+
) {
419427
return {
420428
start: reply.start,
421429
end: reply.end,

0 commit comments

Comments
 (0)