Fix: lsp_bridge.py raises a KeyError
when a code action is triggered in tramp.
#1113
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.
Problem
When I triggered a code action in a file over the tramp, the lsp_bridge.py output the following error, and the code action did not work.
Fix
The
item["edit"]
is assumed to be a WorkspaceEdit instance and it looks to have one of (changes
ordocumentChanges
).See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceEdit
Since the current version only supports the
changes
case, I added an implementation to supportdocumentChanges
to fix the problem.Note
Although I have implemented cases for all documentChanges types (TextDocumentEdit, CreateFile, DeleteFile, RenameFile), I was only able to confirm the case of TextDocumentEdit that is returned in
code_action.py
andrename.py
. I could not test the other types, CreateFile, DeleteFile, and RenameFile, because I am not sure in what use cases lsp would return these operations.I would appreciate it if you could confirm this.