mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
* Fixed a bug where using `yas/also-auto-indent-first-line' would
likely mess up undo.
This commit is contained in:
parent
859ae946da
commit
3dae4c6db3
13
yasnippet.el
13
yasnippet.el
@ -3030,9 +3030,18 @@ will be deleted before inserting template."
|
||||
;; the new snippet (without the "key") followed by an apply of
|
||||
;; `yas/take-care-of-redo' on the newly inserted snippet boundaries
|
||||
;;
|
||||
(let ((start (overlay-start (yas/snippet-control-overlay snippet)))
|
||||
;; A small exception, if `yas/also-auto-indent-first-line'
|
||||
;; is t and `yas/indent' decides to indent the line to a
|
||||
;; point before the actual expansion point, undo would be
|
||||
;; messed up. We call the early point "newstart"". case,
|
||||
;; and attempt to fix undo.
|
||||
;;
|
||||
(let ((newstart (overlay-start (yas/snippet-control-overlay snippet)))
|
||||
(end (overlay-end (yas/snippet-control-overlay snippet))))
|
||||
(push (cons start end) buffer-undo-list)
|
||||
(when (< newstart start)
|
||||
|
||||
(push (cons (make-string (- start newstart) ? ) newstart) buffer-undo-list))
|
||||
(push (cons newstart end) buffer-undo-list)
|
||||
(push `(apply yas/take-care-of-redo ,start ,end ,snippet)
|
||||
buffer-undo-list))
|
||||
;; Now, move to the first field
|
||||
|
Loading…
x
Reference in New Issue
Block a user