mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 05:03:04 +00:00
Don't indent empty lines in snippet expansion
* yasnippet.el (yas--indent-region): Indent only non-empty lines. * yasnippet-tests.el (basic-indentation): Add empy and non-empty (but blank) lines in test snippet.
This commit is contained in:
parent
bdfab67eac
commit
146b161112
@ -200,9 +200,13 @@
|
|||||||
(set (make-local-variable 'yas-indent-line) 'auto)
|
(set (make-local-variable 'yas-indent-line) 'auto)
|
||||||
(set (make-local-variable 'yas-also-auto-indent-first-line) t)
|
(set (make-local-variable 'yas-also-auto-indent-first-line) t)
|
||||||
(yas-expand-snippet "def ${1:method}${2:(${3:args})}\n$0\nend")
|
(yas-expand-snippet "def ${1:method}${2:(${3:args})}\n$0\nend")
|
||||||
|
;; Note that empty line is not indented.
|
||||||
|
(should (string= "def method(args)
|
||||||
|
|
||||||
|
end" (buffer-string)))
|
||||||
(cl-loop repeat 3 do (ert-simulate-command '(yas-next-field)))
|
(cl-loop repeat 3 do (ert-simulate-command '(yas-next-field)))
|
||||||
(yas-mock-insert (make-string (random 5) ?\ )) ; purposedly mess up indentation
|
(yas-mock-insert (make-string (random 5) ?\ )) ; purposedly mess up indentation
|
||||||
(yas-expand-snippet "class << ${self}\n$0\nend")
|
(yas-expand-snippet "class << ${self}\n $0\nend")
|
||||||
(ert-simulate-command '(yas-next-field))
|
(ert-simulate-command '(yas-next-field))
|
||||||
(should (string= "def method(args)
|
(should (string= "def method(args)
|
||||||
class << self
|
class << self
|
||||||
|
@ -3918,7 +3918,8 @@ The SNIPPET's markers are preserved."
|
|||||||
(goto-char from)
|
(goto-char from)
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
(cl-loop do
|
;; Indent each non-empty line.
|
||||||
|
(cl-loop if (/= (line-beginning-position) (line-end-position)) do
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(let ((trouble-markers ; The markers at (point).
|
(let ((trouble-markers ; The markers at (point).
|
||||||
(cl-remove (point) snippet-markers :test #'/=)))
|
(cl-remove (point) snippet-markers :test #'/=)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user