refactor: make LspApplyDocumentEditCommand take plain TextEdits #2393
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.
Refactor per discussion in #2389 (comment)
lsp_apply_document_edit
take[TextEdit]
rather than parsed custom structure.LSP.plugin.core.edit.apply_workspace_edit
function (usesession.apply_workspace_edit_async
instead)LSP.plugin.formatting.apply_text_edits_to_view
function (useLSP.plugin.apply_text_edits
instead)LSP.plugin.core.edit.parse_text_edit
toLSP.plugin.edit._parse_text_edit
(and make "private")LSP.plugin.core.edit.parse_workspace_edit
function (returns unparsed edits)apply_text_edits
as a public APIIn one test I had to change the test for overflow handling from passing
sys.maxsize + 1
offset toUINT_MAX + 1
offset because ST API won't allowsys.maxsize + 1
. I guess this could be one minor reason why parsing before triggeringlsp_apply_document_edit
was there but since LSP spec limits toUINT_MAX
anyway, it should be fine.Note that changes to those private APIs would break a couple of LSP packages so I'll be creating PRs for those and linking here.
Also note that I've exposed
apply_text_edits
as a public API since I am very much in favor of exposing an API function rather than LSP packages calling the ST command directly since the latter is not type-checked.Needs to be released simultaneously with: