eclipse-lsp4e / eclipse-lsp4e/lsp4e
Additional requests for incomplete completion lists should pass `completionTriggerKind=TriggerForIncompleteCompletions`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 85
- Forks
- 69
- Avg merge
- 8h 33m
- Merged PRs (30d)
- 6
Description
When a LS marks the list of completions as incomplete, the spec says that the client must send further textDocument/completion requests for each additionally typed character, see doc of isIncomplete. The spec also says, that further requests should use CompletionTriggerKind.TriggerForIncompleteCompletions. However, LSP4E currently does not honor this part of the spec.
In our use-case, with the basedpyright LS, this leads to the behavior, that the server keeps marking the response as incomplete, because it will only mark the third subsequent completion result as complete. This leads to the annoying behavior, that the completion popup is reopened constantly (which also triggers #1448)
I tried to solve this, but wasn't able to get anywhere. But I thought I document my findings, in case someone else wants to have a go at it.
- We need to know whether a user started a new completion session, i.e. by pressing ctrl+space (use
CompletionTriggerKind.Invoked) or typing a trigger character (useCompletionTriggerKind.TriggerCharacter) or if he kept typing with the completion window still open (and the list being incomplete, -> useCompletionTriggerKind.TriggerForIncompleteCompletions) - It's possible to implement a
org.eclipse.jface.text.contentassist.ICompletionListener. This would allow us to know whether a new completion session was started, in which case we could sendCompletionTriggerKind.InvokedorCompletionTriggerKind.TriggerCharacterfor the first request andTriggerForIncompleteCompletionsfor further requests, if the returned list was incomplete. - Eclipse (i.e. org.eclipse.jface.text.contentassist) only computes the completions on the first typed character and afterwards uses
org.eclipse.jface.text.contentassist.ICompletionProposalExtension2.validate(IDocument, int, DocumentEvent)to filter the resulting list with respect to any further typed characters. The only exception to this is, when all Proposal say they are invalid, then another computation is triggered. LSP4E currently uses this to trick Eclipse into another computation, by saying that completions which are incomplete are only valid for the offset at which the first request was sent. However, this causes the completion popup to be closed and re-openend after each character. This also causes a restart of the completion session, which makes ourICompletionListeneruseless, because we can't distinguish, if the user actually started a new completion session, or if it was just the completion proposal popup which decided to close and reopen.
I think we would need to make some changes (or bug fixes) to the org.eclipse.jface.text.contentassist API, but that is probably quite the hassle.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the completion handling involving org.eclipse.jface.text.contentassist.ICompletionListener and ICompletionProposalExtension2, then compare it with CompletionTriggerKind and the LSP completion specification. Determine how a completion session can distinguish initial requests from subsequent incomplete-list requests without reopening the popup. Done means additional requests use TriggerForIncompleteCompletions while preserving normal session behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100