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.
This commit is contained in:
João Távora 2020-05-24 23:15:49 +01:00
parent 5b1217ab08
commit d3d6d70b1c

View File

@ -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))