Skip to content

Commit

Permalink
Merge pull request #391 from krassowski/fix-388-do-not-hint-if-only-m…
Browse files Browse the repository at this point in the history
…atch-same-as-token

Fix continuous hinting showing up when it has nothing to offer
  • Loading branch information
krassowski authored Oct 25, 2020
2 parents 6b868d2 + e6095cd commit 6bd8831
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

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

[#387]: https://github.com/krassowski/jupyterlab-lsp/issues/387
[#389]: https://github.com/krassowski/jupyterlab-lsp/issues/389
[#391]: https://github.com/krassowski/jupyterlab-lsp/issues/391

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

Expand Down
8 changes: 8 additions & 0 deletions atest/05_Features/Completion.robot
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ Works In File Editor
Completer Should Suggest add
[Teardown] Clean Up After Working With File completion.py

Continious Hinting Works
Configure JupyterLab Plugin {"continuousHinting": true} plugin id=${COMPLETION PLUGIN ID}
Prepare File for Editing Python completion completion.py
Place Cursor In File Editor At 9 2
Capture Page Screenshot 01-editor-ready.png
Press Keys None d
Completer Should Suggest addition

Autocompletes If Only One Option
Enter Cell Editor 3 line=1
Press Keys None cle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class LSPConnector
}

return promise.then(reply => {
reply = this.suppress_if_needed(reply);
reply = this.suppress_if_needed(reply, token);
this.trigger_kind = CompletionTriggerKind.Invoked;
return reply;
});
Expand Down Expand Up @@ -413,9 +413,17 @@ export class LSPConnector
return Promise.resolve(undefined);
}

private suppress_if_needed(reply: CompletionHandler.ICompletionItemsReply) {
private suppress_if_needed(
reply: CompletionHandler.ICompletionItemsReply,
token: CodeEditor.IToken
) {
if (this.trigger_kind == AdditionalCompletionTriggerKinds.AutoInvoked) {
if (reply.start == reply.end) {
if (
// do not auto-invoke if no match found
reply.start == reply.end ||
// do not auto-invoke if only one match found and this match is exactly the same as the current token
(reply.items.length === 1 && reply.items[0].insertText === token.value)
) {
return {
start: reply.start,
end: reply.end,
Expand Down

0 comments on commit 6bd8831

Please sign in to comment.