mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Update `yas--take-care-of-redo' call in buffer undo list
On 2018-01-01 "Fix undo when first line indentation moves snippet forward", `yas--take-care-of-redo' removed the BEG and END arguments, but the call added to `buffer-undo-list' from `yas--snippet-revive', was not updated accordingly. * yasnippet.el (yas--snippet-revive): Remove `beg' and `end' from `yas--take-care-of-redo' entry. * yasnippet-tests.el (undo-redo): New test.
This commit is contained in:
parent
203059a95e
commit
16c2b38bce
@ -297,6 +297,30 @@ attention to case differences."
|
||||
;; (should (string= (yas--buffer-contents)
|
||||
;; "brother from another mother!"))))
|
||||
|
||||
(ert-deftest undo-redo ()
|
||||
"Check redoing of snippet undo."
|
||||
(yas-with-snippet-dirs '((".emacs.d/snippets"
|
||||
("emacs-lisp-mode" ("x" . "${1:one},and done"))))
|
||||
(with-temp-buffer
|
||||
(emacs-lisp-mode)
|
||||
(yas-reload-all)
|
||||
(yas-minor-mode 1)
|
||||
(yas-expand-snippet "x$0")
|
||||
(let ((pre-expand-string (buffer-string)))
|
||||
(setq buffer-undo-list nil)
|
||||
(ert-simulate-command '(yas-expand))
|
||||
(push nil buffer-undo-list)
|
||||
(ert-simulate-command '(yas-next-field)) ; $1 -> exit snippet.
|
||||
(should (string-match-p "\\`one,and done" (buffer-string)))
|
||||
(push nil buffer-undo-list)
|
||||
(ert-simulate-command '(undo)) ; Revive snippet.
|
||||
(ert-simulate-command '(undo)) ; Undo expansion.
|
||||
(should (string= (buffer-string) pre-expand-string))
|
||||
(ert-simulate-command '(move-end-of-line 1))
|
||||
(push nil buffer-undo-list)
|
||||
(ert-simulate-command '(undo)) ; Redo (re-expand snippet).
|
||||
(should (string-match-p "\\`one,and done" (buffer-string)))))))
|
||||
|
||||
(defun yas-test-expand-and-undo (mode snippet-entry initial-contents)
|
||||
(yas-with-snippet-dirs
|
||||
`((".emacs.d/snippets" (,(symbol-name mode) ,snippet-entry)))
|
||||
|
@ -3869,7 +3869,7 @@ After revival, push the `yas--take-care-of-redo' in the
|
||||
(when (yas--maybe-move-to-active-field snippet)
|
||||
(setf (yas--snippet-control-overlay snippet) (yas--make-control-overlay snippet beg end))
|
||||
(overlay-put (yas--snippet-control-overlay snippet) 'yas--snippet snippet)
|
||||
(push `(apply yas--take-care-of-redo ,beg ,end ,snippet)
|
||||
(push `(apply yas--take-care-of-redo ,snippet)
|
||||
buffer-undo-list)))
|
||||
|
||||
(defun yas--snippet-create (content expand-env begin end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user