diff --git a/yasnippet-tests.el b/yasnippet-tests.el index b0906d5..c5fd376 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -38,14 +38,17 @@ (ert-deftest field-navigation () (with-temp-buffer (yas-minor-mode 1) - (yas-expand-snippet "${1:brother} from another ${2:mother}") + (yas-expand-snippet "${1:brother} from ${2:another} ${3:mother}") (should (string= (yas--buffer-contents) "brother from another mother")) - (should (looking-at "brother")) (ert-simulate-command '(yas-next-field-or-maybe-expand)) + (should (looking-at "another")) + (ert-simulate-command '(yas-next-field-or-maybe-expand)) (should (looking-at "mother")) (ert-simulate-command '(yas-prev-field)) + (should (looking-at "another")) + (ert-simulate-command '(yas-prev-field)) (should (looking-at "brother")))) (ert-deftest simple-mirror () diff --git a/yasnippet.el b/yasnippet.el index 79861ee..cae33a0 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -3079,8 +3079,7 @@ Otherwise delegate to `yas-next-field'." (and (not (eq field active)) (yas--field-probably-deleted-p snippet field))) (yas--snippet-fields snippet)))) - (if (>= n 0) (nth n (memq active live-fields)) - (car (last (memq active (reverse live-fields)) (- n)))))) + (nth (abs n) (memq active (if (>= n 0) live-fields (reverse live-fields)))))) (defun yas-next-field (&optional arg) "Navigate to the ARGth next field.