Skip to content

Commit

Permalink
Close #64: handle edits to same position in the correct order
Browse files Browse the repository at this point in the history
In eglot--apply-text-edits, the markers returned by
eglot--lsp-position-to-point are of the "stay" type, i.e. have an
insertion-type of nil.  This causes multiple insertion edits to the
same location to happen in the reverse order in which they appear in
the LSP message, which is a violation of the spec and a bug.

There are more ways to solve this (see related discuttion in
joaotavora/eglot#64), but the easiest way is
to revert the order in which the edits are processed.  This is because
the spec tells us that the order is only relevant in precisely this
"same position" case.  So if we reverse the order we fix this bug and
don't break anything else.

* eglot.el (eglot--apply-text-edits): Apply edits in reverse..

#64: joaotavora/eglot#64
  • Loading branch information
joaotavora committed Aug 13, 2018
1 parent 03a99da commit eed4959
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp."
(progress-reporter-update reporter (cl-incf done)))))))
(mapcar (jsonrpc-lambda (&key range newText)
(cons newText (eglot--range-region range 'markers)))
edits))
(reverse edits)))
(undo-amalgamate-change-group change-group)
(progress-reporter-done reporter))))

Expand Down

0 comments on commit eed4959

Please sign in to comment.