Apply additionalTextEdits from completion items #7

Open
ondrejmirtes wants to merge 1 commit from ondrejmirtes/lsp-client:additional-text-edits into main
First-time contributor

Completion items can carry additionalTextEdits -- most commonly an auto-import
(a use statement that makes the inserted name valid). serverCompletion
ignored them, so accepting e.g. a class completion inside a namespace inserted a
bare name without its import.

This applies the additionalTextEdits along with the completion, remapping the
completion range through them so positions stay correct. Includes a test.

Note: this touches the same apply code as the snippet-escapes PR, so it will
conflict with that one -- happy to rebase whichever lands second.

Completion items can carry additionalTextEdits -- most commonly an auto-import (a `use` statement that makes the inserted name valid). serverCompletion ignored them, so accepting e.g. a class completion inside a namespace inserted a bare name without its import. This applies the additionalTextEdits along with the completion, remapping the completion range through them so positions stay correct. Includes a test. Note: this touches the same `apply` code as the snippet-escapes PR, so it will conflict with that one -- happy to rebase whichever lands second.
A completion item can carry additionalTextEdits -- most commonly an auto-import
(a `use` statement that makes the inserted name valid). These were ignored, so
accepting such a completion inserted a bare name without its import. Apply them
along with the completion, remapping the completion range through the edits so
positions stay correct.
Owner

We'll need to also implement CompletionResult.map for this to be sound. If some change that doesn't affect the cursor or the text immediately around the selection comes in while a completion is active, it will be preserved, even though the document is no longer precisely what it was when the completion was queries. Same if such changes happen while the completion is being fetched.

We'll need to also implement [`CompletionResult.map`](https://codemirror.net/docs/ref/#autocomplete.CompletionResult.map) for this to be sound. If some change that doesn't affect the cursor or the text immediately around the selection comes in while a completion is active, it will be preserved, even though the document is no longer precisely what it was when the completion was queries. Same if such changes happen while the completion is being fetched.
This pull request has changes conflicting with the target branch.
  • src/completion.ts
  • test/server.ts
  • test/webtest-client.ts
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u additional-text-edits:ondrejmirtes-additional-text-edits
git switch ondrejmirtes-additional-text-edits

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff ondrejmirtes-additional-text-edits
git switch ondrejmirtes-additional-text-edits
git rebase main
git switch main
git merge --ff-only ondrejmirtes-additional-text-edits
git switch ondrejmirtes-additional-text-edits
git rebase main
git switch main
git merge --no-ff ondrejmirtes-additional-text-edits
git switch main
git merge --squash ondrejmirtes-additional-text-edits
git switch main
git merge --ff-only ondrejmirtes-additional-text-edits
git switch main
git merge ondrejmirtes-additional-text-edits
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/lsp-client!7
No description provided.