From e609841f6f987698e41e362b397c0130fa4103e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 14 Dec 2020 17:08:26 +0000 Subject: [PATCH] Don't let m-x fill-paragraph break didchange M-x fill-paragraph represents some paragraph-fillling changes very summarily. Filling 1 // foo 2 bar Into 1 // foo bar Only makes two changes: a deletion of the "// " and a replacement of a newline with a space character. The second change fooled Eglot's fix for https://github.com/joaotavora/eglot/issues/259, by making a change similar to the one it is made to detect and correct. That fix should taget things that happen on the same line, this not being one of those things. * eglot.el (eglot--after-change): Only apply fix to https://github.com/joaotavora/eglot/issues/259 if case-fiddling happens on same line. GitHub-reference: fix https://github.com/joaotavora/eglot/issues/367 --- lisp/progmodes/eglot.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index b0bd213b48d..aa89ae98c67 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1745,10 +1745,15 @@ Records BEG, END and PRE-CHANGE-LENGTH locally." ;; github#259: With `upcase-word' or somesuch, ;; `before-change-functions' always records the whole word's ;; `beg' and `end'. Not only is this longer than needed but - ;; conflicts with the args received here. Detect this using - ;; markers recorded earlier and `pre-change-len', then fix it. + ;; conflicts with the args received here, which encompass just + ;; the parts of the word that changed (if any). We detect this + ;; using markers recorded earlier and at looking + ;; `pre-change-len'. We also ensure that the before bounds + ;; indeed belong to the same line (if we don't, we get could get + ;; #367). (when (and (= b-end b-end-marker) (= b-beg b-beg-marker) - (not (zerop pre-change-length))) + (not (zerop pre-change-length)) + (= (plist-get lsp-beg :line) (plist-get lsp-end :line))) (setq lsp-end (eglot--pos-to-lsp-position end) lsp-beg (eglot--pos-to-lsp-position beg))) (setcar eglot--recent-changes -- 2.39.2