Skip to content

Commit 21b9a26

Browse files
committed
Fix continuous hinting showing up when it has nothing to offer
1 parent 80459bf commit 21b9a26

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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)