From: João Távora Date: Mon, 13 Aug 2018 00:45:40 +0000 (+0100) Subject: Handle edits to same position in the correct order X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~447 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b5e28c2ea6434d6216d927bac169bbdb089da969;p=emacs.git Handle edits to same position in the correct order 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 https://github.com/joaotavora/eglot/pull/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.. GitHub-reference: close https://github.com/joaotavora/eglot/issues/64 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index eeea104e04c..427fa293b68 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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))))