From d3d6d70b1cd4818d271752468e0fdb0788db750d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 24 May 2020 23:15:49 +0100 Subject: [PATCH] Correct manual call to after-change-functions The pre-change-len argument passed to each element of after-change-fucntions must reflect the length of the affected region before the change happened. In Yasnippet's case, the change enacted in yas--snippet-create is the replacement of a region (which is almost always of length 0) with a ready-to-navigate snippet template. The previous implementation calculated the length of the affected region after that change happened, which is wrong. See https://github.com/joaotavora/eglot/issues/462 for a case where this mattered. * yasnippet.el (yas--snippet-create): Correct manual call to after-change-functions. --- yasnippet.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yasnippet.el b/yasnippet.el index ac25669..fe29fc9 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -4188,7 +4188,7 @@ Returns the newly created snippet." (yas--snippet-parse-create snippet)) (run-hook-with-args 'after-change-functions (point-min) (point-max) - (- (point-max) (point-min)))) + (- end begin))) (when (listp buffer-undo-list) (push (cons (point-min) (point-max)) buffer-undo-list))