[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 476bc77 35/42: Fix snippet undo
From: |
Noam Postavsky |
Subject: |
[elpa] master 476bc77 35/42: Fix snippet undo |
Date: |
Sun, 22 Dec 2019 17:38:02 -0500 (EST) |
branch: master
commit 476bc77c34edc9ff24ed39c55ab1b1baa103d39a
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Fix snippet undo
* yasnippet.el (yas--snippet-revive): Add revived snippet to
yas--active-snippets.
* yasnippet-debug.el (yas-debug-snippets): Print yas--active-snippets
length.
* yasnippet-tests.el (undo-revive-and-do-again): New test.
---
yasnippet-debug.el | 2 ++
yasnippet-tests.el | 25 +++++++++++++++++++++++++
yasnippet.el | 1 +
3 files changed, 28 insertions(+)
diff --git a/yasnippet-debug.el b/yasnippet-debug.el
index 38d7a3a..d33e8a5 100644
--- a/yasnippet-debug.el
+++ b/yasnippet-debug.el
@@ -254,6 +254,8 @@ buffer-locally, otherwise install it globally. If HOOK is
(setq yas-debug-target-snippets
(cl-delete-if-not #'yas--snippet-p
yas-debug-target-snippets)))
(let ((yas-debug-recently-live-indicators nil))
+ (printf "(length yas--snippets-snippets) => %d\n"
+ (length yas--active-snippets))
(dolist (snippet (or yas-debug-target-snippets
(yas-active-snippets)))
(printf "snippet %d\n" (yas--snippet-id snippet))
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 7791db8..cdd42bf 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -346,6 +346,31 @@ attention to case differences."
(ert-simulate-command '(undo)) ; Redo (re-expand snippet).
(should (string-match-p "\\`one,and done" (buffer-string)))))))
+(ert-deftest undo-revive-and-do-again ()
+ "Check undo-revived snippet is properly ended."
+ ;; See https://github.com/joaotavora/yasnippet/issues/1006.
+ (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")
+ (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.
+ (yas-mock-insert "abc")
+ (ert-simulate-command '(yas-next-field)) ; $1 -> exit snippet again.
+ (should (string-match-p "\\`abc,and done" (buffer-string)))
+ ;; We should have exited snippet and cleaned up any overlays.
+ (should-not (cl-some (lambda (o) (overlay-get o 'yas--snippet))
+ (overlays-in (point-min) (point-max)))))))
+
+
(defun yas-test-expand-and-undo (mode snippet-entry initial-contents)
(yas-with-snippet-dirs
`((".emacs.d/snippets" (,(symbol-name mode) ,snippet-entry)))
diff --git a/yasnippet.el b/yasnippet.el
index 9951940..67cecb8 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -4149,6 +4149,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 snippet yas--active-snippets)
(when (listp buffer-undo-list)
(push `(apply yas--take-care-of-redo ,snippet)
buffer-undo-list))))
- [elpa] master 6a3619b 23/42: Fix additional corner case with org source block integration, (continued)
- [elpa] master 6a3619b 23/42: Fix additional corner case with org source block integration, Noam Postavsky, 2019/12/22
- [elpa] master 9cedd59 25/42: Allow disabling snippet keybindings from hook, Noam Postavsky, 2019/12/22
- [elpa] master 55c448b 32/42: Remove redundant arg to yas-expand-snippet, Noam Postavsky, 2019/12/22
- [elpa] master 189f737 26/42: * doc/faq.org: Note that Flyspell problem is (now fixed) Emacs bug., Noam Postavsky, 2019/12/22
- [elpa] master ffce236 30/42: Do auto indentation only in post command hook, Noam Postavsky, 2019/12/22
- [elpa] master 760f77a 12/42: Test for mirroring more than one field, Noam Postavsky, 2019/12/22
- [elpa] master 0f05a75 14/42: Add yas-completing-read, Noam Postavsky, 2019/12/22
- [elpa] master 03aa561 19/42: * doc/snippet-organization.org: Fix typo., Noam Postavsky, 2019/12/22
- [elpa] master 9f51cf2 17/42: Register snippet movement comments for eldoc, Noam Postavsky, 2019/12/22
- [elpa] master 6a738b5 29/42: ; doc/faq.org: Fix example keybinding code., Noam Postavsky, 2019/12/22
- [elpa] master 476bc77 35/42: Fix snippet undo,
Noam Postavsky <=
- [elpa] master c432e78 31/42: Fix field adjustment on deletion, Noam Postavsky, 2019/12/22
- [elpa] master f056a4d 33/42: Minor code shuffling and commenting, Noam Postavsky, 2019/12/22
- [elpa] master bd3572a 36/42: Handle multiple uses of yas-auto-next, Noam Postavsky, 2019/12/22
- [elpa] master e45e3de 34/42: * doc/faq.org: yas-prev should be yas-prev-field, Noam Postavsky, 2019/12/22
- [elpa] master a66f15e 38/42: Fix yas-insert-snippet for keyless snippets, Noam Postavsky, 2019/12/22
- [elpa] master d91dd66 37/42: * yasnippet.el (yas--extra-modes): Move alias before def, Noam Postavsky, 2019/12/22
- [elpa] master 1bee3a3 39/42: Fix #979: grok curly braces with LSP-style escaping, Noam Postavsky, 2019/12/22
- [elpa] master 3bf9a3b 41/42: Release 0.14.0, Noam Postavsky, 2019/12/22
- [elpa] master 4046f61 40/42: * yasnippet.el (yas-field-highlight-face): Remove redundant quote., Noam Postavsky, 2019/12/22
- [elpa] master 32f3512 42/42: * packages/yasnippet: Merge 0.14.0 from upstream., Noam Postavsky, 2019/12/22