Skip to content

Commit a4f21ae

Browse files
authored
Merge pull request #434 from krassowski/fix-autoinvoke-on-dot
Ensure that trigger characters auto-invoke works with continuous hinting
2 parents 87b0f93 + 383a66b commit a4f21ae

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
- bug fixes
66
- improved performance of completion and highlights by minimising the number of highlight requests and GUI redraws (token checking, debouncing, acting on a single response only) ([#433])
77
- highlights now update after cell focus/blur events even if those do not trigger cursor movement ([#433])
8+
- trigger characters auto-invoke now works in continuous hinting mode again ([#434])
89

910
[#433]: https://github.com/krassowski/jupyterlab-lsp/issues/433
11+
[#434]: https://github.com/krassowski/jupyterlab-lsp/issues/434
1012

1113
### `@krassowski/jupyterlab-lsp 2.1.1` (2020-12-15)
1214

atest/05_Features/Completion.robot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Continious Hinting Works
5454
Capture Page Screenshot 01-editor-ready.png
5555
Press Keys None d
5656
Completer Should Suggest addition
57+
# gh430 - auto invoke after dot should work too
58+
Press Keys None .
59+
Completer Should Suggest __doc__
5760

5861
Autocompletes If Only One Option
5962
Enter Cell Editor 3 line=1

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,10 @@ export class CompletionCM extends CodeMirrorIntegration {
4444
afterChange(change: CodeMirror.EditorChange): void {
4545
// TODO: maybe the completer could be kicked off in the handleChange() method directly; signature help still
4646
// requires an up-to-date virtual document on the LSP side, so we need to wait for sync.
47-
if (
48-
change.text &&
49-
change.text[0].length == 1 &&
50-
this.settings.composite.continuousHinting
51-
) {
52-
(this.feature.labIntegration as CompletionLabIntegration)
53-
.invoke_completer(AdditionalCompletionTriggerKinds.AutoInvoked)
54-
.catch(console.warn);
55-
return;
56-
}
5747

48+
// note: trigger character completion need to be have a higher priority than auto-invoked completion
49+
// because the latter does not work for on-dot completion due to suppression of trivial suggestions
50+
// see gh430
5851
let last_character = this.extract_last_character(change);
5952
if (this.completionCharacters.indexOf(last_character) > -1) {
6053
this.virtual_editor.console.log(
@@ -64,6 +57,17 @@ export class CompletionCM extends CodeMirrorIntegration {
6457
(this.feature.labIntegration as CompletionLabIntegration)
6558
.invoke_completer(CompletionTriggerKind.TriggerCharacter)
6659
.catch(console.warn);
60+
return;
61+
}
62+
63+
if (
64+
change.text &&
65+
change.text[0].length == 1 &&
66+
this.settings.composite.continuousHinting
67+
) {
68+
(this.feature.labIntegration as CompletionLabIntegration)
69+
.invoke_completer(AdditionalCompletionTriggerKinds.AutoInvoked)
70+
.catch(console.warn);
6771
}
6872
}
6973
}

0 commit comments

Comments
 (0)