Closes #562: Deleting inner numberless snippet causes error

* yasnippet.el (yas--field-probably-deleted-p): Protect against
nil `yas--field-number'.

* yasnippet-tests.el (delete-numberless-inner-snippet-issue-562): New test
This commit is contained in:
João Távora 2015-03-23 09:50:54 +00:00
parent d19ef74634
commit 316435e03e
2 changed files with 13 additions and 1 deletions

View File

@ -112,6 +112,17 @@
(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)

View 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.