mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 05:03:04 +00:00
Don't set yas-selected-text to non-selected text
* yasnippet.el (yas-expand-snippet): Only use the `to-delete' text if `region-active-p' return true. * yasnippet-tests.el (expand-with-unused-yas-selected-text): New test.
This commit is contained in:
parent
ce11fd6690
commit
04062d8b4f
@ -625,6 +625,19 @@ mapconcat #'(lambda (arg)
|
|||||||
(yas-expand-snippet "${1:$$(if (not yas-modified-p) \"a\")}")
|
(yas-expand-snippet "${1:$$(if (not yas-modified-p) \"a\")}")
|
||||||
(yas-expand-snippet "\\\\alpha")))
|
(yas-expand-snippet "\\\\alpha")))
|
||||||
|
|
||||||
|
(ert-deftest expand-with-unused-yas-selected-text ()
|
||||||
|
(with-temp-buffer
|
||||||
|
(yas-with-snippet-dirs
|
||||||
|
'((".emacs.d/snippets"
|
||||||
|
("emacs-lisp-mode"
|
||||||
|
("foo" . "expanded `yas-selected-text`foo"))))
|
||||||
|
(yas-reload-all)
|
||||||
|
(emacs-lisp-mode)
|
||||||
|
(yas-minor-mode +1)
|
||||||
|
(insert "foo")
|
||||||
|
(ert-simulate-command '(yas-expand))
|
||||||
|
(should (equal (buffer-string) "expanded foo")))))
|
||||||
|
|
||||||
(ert-deftest example-for-issue-271 ()
|
(ert-deftest example-for-issue-271 ()
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(yas-minor-mode 1)
|
(yas-minor-mode 1)
|
||||||
|
@ -3779,8 +3779,10 @@ considered when expanding the snippet."
|
|||||||
(to-delete (and (> end start)
|
(to-delete (and (> end start)
|
||||||
(buffer-substring-no-properties start end)))
|
(buffer-substring-no-properties start end)))
|
||||||
(yas-selected-text
|
(yas-selected-text
|
||||||
(or yas-selected-text
|
(cond (yas-selected-text)
|
||||||
(if (not clear-field) to-delete)))
|
((and (region-active-p)
|
||||||
|
(not clear-field))
|
||||||
|
to-delete)))
|
||||||
snippet)
|
snippet)
|
||||||
(goto-char start)
|
(goto-char start)
|
||||||
(setq yas--indent-original-column (current-column))
|
(setq yas--indent-original-column (current-column))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user