mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Fix field navigation in the backwards direction
* yasnippet.el (yas--find-next-field): For negative N, actually give the Nth previous field, not the 1st field. * yasnippet-tests.el (field-navigation): Add a 3rd field, and test calling `yas-prev-field' while on it. Fixes #722.
This commit is contained in:
parent
0db65ee0bb
commit
9500b000fd
@ -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 ()
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user