]> code.delx.au - gnu-emacs-elpa/commitdiff
Closes #562: Deleting inner numberless snippet causes error
authorJoão Távora <joaotavora@gmail.com>
Mon, 23 Mar 2015 09:50:54 +0000 (09:50 +0000)
committerJoão Távora <joaotavora@gmail.com>
Mon, 23 Mar 2015 10:11:06 +0000 (10:11 +0000)
* yasnippet.el (yas--field-probably-deleted-p): Protect against
nil `yas--field-number'.

* yasnippet-tests.el (delete-numberless-inner-snippet-issue-562): New test

yasnippet-tests.el
yasnippet.el

index 74996403bc098bd9ba052f4345efa2a800d12614..150e1d07f2c8dc30090650d126844038b7b15678 100644 (file)
     (ert-simulate-command `(yas-mock-insert "abc"))
     (should (string= (yas--buffer-contents) "abcabcabcabc"))))
 
+(ert-deftest delete-numberless-inner-snippet-issue-562 ()
+  (with-temp-buffer
+    (yas-minor-mode 1)
+    (yas-expand-snippet "${3:${test}bla}$0${2:ble}")
+    (ert-simulate-command '(yas-next-field-or-maybe-expand))
+    (should (looking-at "testblable"))
+    (ert-simulate-command '(yas-next-field-or-maybe-expand))
+    (ert-simulate-command '(yas-skip-and-clear-or-delete-char))
+    (should (looking-at "ble"))
+    (should (null (yas--snippets-at-point)))))
+
 ;; (ert-deftest in-snippet-undo ()
 ;;   (with-temp-buffer
 ;;     (yas-minor-mode 1)
index 8c9212c624271fc6819a46c84cab0ecb1619c648..2a2254bb3b9c2b936a58a90aed24d2e911a1cec4 100644 (file)
@@ -3016,7 +3016,8 @@ through the field's start point"
    ;; the field numbered 0, just before the exit marker, should
    ;; never be skipped
    ;;
-   (not (zerop (yas--field-number field)))))
+   (not (and (yas--field-number field)
+             (zerop (yas--field-number field))))))
 
 (defun yas--snippets-at-point (&optional all-snippets)
   "Return a sorted list of snippets at point.