mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-15 22:13:04 +00:00
fix: must sometimes chain object to the end of parent of previous object
This commit is contained in:
parent
ff48006f55
commit
ef1747d947
@ -48,6 +48,18 @@
|
|||||||
(&field 3 "field")))
|
(&field 3 "field")))
|
||||||
(&mirror 3 (concat ", nested mirroring: "
|
(&mirror 3 (concat ", nested mirroring: "
|
||||||
field-string))))
|
field-string))))
|
||||||
|
(more-nesting ("a "
|
||||||
|
(&field 1 (&nested
|
||||||
|
"'"
|
||||||
|
(&field 2 "rain")
|
||||||
|
(&mirror 2 (apply #'string
|
||||||
|
(reverse
|
||||||
|
(string-to-list
|
||||||
|
field-string))))
|
||||||
|
"'"))
|
||||||
|
(&field 3 " and a field:")
|
||||||
|
" "
|
||||||
|
(&mirror 1)))
|
||||||
(printf ("printf (\""
|
(printf ("printf (\""
|
||||||
(&field 1 "%s")
|
(&field 1 "%s")
|
||||||
(&mirror 1 (if (string-match "%" field-string) "\"," "\")"))
|
(&mirror 1 (if (string-match "%" field-string) "\"," "\")"))
|
||||||
@ -156,6 +168,19 @@
|
|||||||
(ert-simulate-command '((lambda () (interactive) (insert "foo"))))
|
(ert-simulate-command '((lambda () (interactive) (insert "foo"))))
|
||||||
(should (equal (buffer-string) "a nested foo, nested mirroring: foo"))))
|
(should (equal (buffer-string) "a nested foo, nested mirroring: foo"))))
|
||||||
|
|
||||||
|
(ert-deftest more-nesting ()
|
||||||
|
(with-temp-buffer
|
||||||
|
(snippet--insert-test-snippet 'more-nesting)
|
||||||
|
(should (equal (buffer-string) "a 'rainniar' and a field: 'rainniar'"))
|
||||||
|
(ert-simulate-command '((lambda () (interactive) (insert "bar"))))
|
||||||
|
(should (equal (buffer-string) "a bar and a field: bar"))
|
||||||
|
(ert-simulate-command '(snippet-next-field))
|
||||||
|
(ert-simulate-command '((lambda () (interactive) (insert "baz"))))
|
||||||
|
(should (equal (buffer-string) "a barbaz bar"))
|
||||||
|
(ert-simulate-command '(snippet-prev-field))
|
||||||
|
(ert-simulate-command '((lambda () (interactive) (insert "foo"))))
|
||||||
|
(should (equal (buffer-string) "a foobarbaz foobar"))))
|
||||||
|
|
||||||
(ert-deftest printf-expansion ()
|
(ert-deftest printf-expansion ()
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(snippet--insert-test-snippet 'printf)
|
(snippet--insert-test-snippet 'printf)
|
||||||
|
@ -270,6 +270,12 @@ meaning is not decided yet"
|
|||||||
(cond ((and parent
|
(cond ((and parent
|
||||||
(= (point) (snippet--object-start parent)))
|
(= (point) (snippet--object-start parent)))
|
||||||
(snippet--object-start parent))
|
(snippet--object-start parent))
|
||||||
|
((and prev
|
||||||
|
(snippet--object-parent prev)
|
||||||
|
(= (point) (snippet--object-end
|
||||||
|
(snippet--object-parent prev))))
|
||||||
|
(snippet--object-end
|
||||||
|
(snippet--object-parent prev)))
|
||||||
((and prev
|
((and prev
|
||||||
(= (point) (snippet--object-end prev)))
|
(= (point) (snippet--object-end prev)))
|
||||||
(snippet--object-end prev))
|
(snippet--object-end prev))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user