Repository navigation
fix: send the inline completion trigger and the selected popup item - #1715
Merged
angelozerr merged 3 commits intoOct 19, 2026
Merged
Conversation
Inline completion always told the server it was triggered automatically and never described the completion popup's selected item: LSPInlineCompletionSupport replaced every context with InlineCompletionTriggerKind.Automatic, and the cache was keyed by caret offset only, so an explicit invocation, or another selected item at the same caret, reused the earlier automatic response. The provider now builds the context: Invoked for a direct call (an explicit user gesture), Automatic otherwise, and selectedCompletionInfo from the visible popup's item, with its edit text and range (a snippet's source notation is not reported as literal text). The support keeps that context, maps the URI per server without changing the caller's parameters, and treats a different context as a different request. As the specification asks, inline completion is requested again when the selected item changes, and a suggestion that does not extend the selected item over the same range is not shown. The selection is read on the EDT, together with the document position, in a cancellable read.
Collaborator
Author
|
The red
#1717 fixes both, together with a third flake. CI needs #1717 merged first; then this branch can be updated from |
Contributor
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Contributor
|
Thanks @lagergren ! |
This was referenced Oct 28, 2026
angelozerr
pushed a commit
that referenced
this pull request
Nov 4, 2026
* docs: describe the 0.30.0 LSP and DAP changes that the docs miss Several changes merged for 0.30.0 changed behavior that the docs describe, or added behavior that they don't. LSPSupport.md still said that pull diagnostics don't support related documents, which #1723 changed. LSP: - LSPSupport.md, Pull Diagnostics: previousResultId, and the relatedDocuments of either kind of report (#1723, #1735), in place of "It doesn't support the related documents." - LSPSupport.md, Inline Completion: the trigger kind and the selected completion item (#1715). - LSPSupport.md, Signature Help: the retrigger, the active parameter of each signature, and signatures without parameters (#1712, #1734). - LSPSupport.md, Formatting: a file without an open editor (#1707). - LSPSupport.md, new Did Change Watched Files section: the directories outside the project that watchers name, and the watchers of a stopped server (#1742). The support list links to it. - UserGuide.md, Formatting: the Do not format patterns (#1817). - UserDefinedLanguageServer.md, Configuration tab: null properties (#1710, #1847) and invalid JSON (#1828). - DeveloperGuide.md, Workspace Configuration: null members of createSettings() (#1710, #1847). DAP, dap/UserGuide.md: - Exception breakpoint: the hint built from exceptionInfo (#1761). The screenshot of the stop at the exception moves back after the example it shows; the Smart Step Into section had come between them. - Large variables: a page with fewer children than asked for is the last one (#1851). Validation: each statement was checked against the code at d1a281d: DocumentContentSynchronizer.refreshPullDiagnostic, LSPInlineCompletionProvider.createParams, LSPParameterInfoHandler, ClientCapabilitiesFactory, AbstractLSPFormattingService.canFormat, LSPFormattingSupport, FileSystemWatchRoots, LanguageServerPanel .validateJsonFields, JsonSettingsTypeAdapterFactory, DAPClient.getExceptionHint and DAPVariableChildren. The other changes merged for 0.30.0 are already documented, by their own PRs, #1784 and #1810, or change nothing that the docs describe. Limits: docs only, no new screenshots, no build run. * docs: say that the JSON fields of a language server are read leniently CodeRabbit noted that "must be valid JSON" is stricter than what LSP4IJ accepts. The dialog's check (LanguageServerPanel.jsonError, JsonParser.parseString) and the readers at run time (SettingsHelper.parseJson, JsonParser.parseReader for the initialization options, experimental and installer, Gson.fromJson for the client configuration and workspace folders) all read leniently. The paragraph now says which JSON is accepted and which isn't. Validation: probed Gson 2.15.0's JsonParser.parseString and Gson.fromJson. Both accept // and /* */ and # comments, unquoted names and single-quoted strings, and both reject a trailing comma, a missing brace and an unescaped backslash, such as in C:\Users.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why?
This makes LSP4IJ's inline completion requests say what the specification says they should; it is not a change of style.
LSPInlineCompletionSupportreplaces the context of each request withInlineCompletionTriggerKind.Automatic. The specification distinguishesInvoked, "Completion was triggered explicitly by a user gesture. Return multiple completion items to enable cycling through them", fromAutomatic, "triggered automatically while editing. It is sufficient to return a single completion item in this case". So when the user explicitly asks for an inline completion, the server is told it may return a single item.selectedCompletionInfo"provides information about the currently selected item in the autocomplete widget if it is visible", and "inline completion providers are requested again whenever the selected item changes". LSP4IJ never sets it and does not request again when the selection changes.How?
LSPInlineCompletionProviderbuilds the context:Invokedfor a direct call,Automaticotherwise, andselectedCompletionInfofrom the visible popup's item, with the item's edit text and range. A snippet's source notation is not reported as literal text, since it can resolve variables and placeholders on insertion. The selection is UI state, so it is read on the EDT together with the document position, in a cancellablereadAction.LSPInlineCompletionSupportkeeps that context, maps the document URI for each server without changing the caller's parameters, and treats a request with a different context as a different request.InlineCompletionEvent.LookupChange), and, as the specification requires, a suggestion that does not extend the selected item over the same range is not shown.Implications
Servers see
Invokedfor explicit invocations, and receive the popup's selected item while the popup is visible. Typing at a new position behaves as before. Inline completion is now requested again when the selected popup item changes, as the specification asks.Changes
LSPInlineCompletionProviderandLSPInlineCompletionSupport.LSPInlineCompletionContextTestsends an automatic request, an explicit one and one with a popup selection at the same caret through the mock server, and checks that each reaches the server with its own context, that an equivalent request reuses the response, and that a changed selection is sent again.LSPInlineCompletionProviderContextTestchecks the context the provider builds:Invokedfor a direct call, the selected item's insertion text and exact edit range, the lookup prefix range when the item has no edit, the selection retained on explicit invocation, and no literal text for a snippet.This relates to the inline completion support tracked in #643. I found no issue or pull request about the trigger kind or the selected item.
Manual verification
To reproduce, use a server that returns different inline completions for
InvokedandAutomatic, or logs the request context, then invoke inline completion explicitly at a position where an automatic suggestion was already shown. Without this change the server receives no new request, and every request it does receive saysAutomatic; with it, the explicit request saysInvoked. I did not run this by hand; the tests above cover it.Automated checks completed:
755ba4d7,LSPInlineCompletionContextTestfails: only 1 of the 3 requests reaches the server (expected:<3> but was:<1>).LSPInlineCompletionProviderContextTestexercises the newcreateParams, which does not exist upstream. All 6 tests pass with this change.76df99e4../gradlew check --rerun-tasks --no-build-cache: 558 tests passed, 3 existing skips (the Docker Bake and Perl inline completion tests), no failures or errors. Run withjava.io.tmpdirunder the home directory, since the default macOS temporary directory gives unrelatedVfsRootAccessfailures with and without this change.