[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 351c1e3 10/40: Don't indent first line of mirrors
From: |
Noam Postavsky |
Subject: |
[elpa] master 351c1e3 10/40: Don't indent first line of mirrors |
Date: |
Wed, 26 Oct 2016 23:06:32 +0000 (UTC) |
branch: master
commit 351c1e3dcbb73e3154aae0755d5b7016f1561ebc
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Don't indent first line of mirrors
* yasnippet.el (yas--mirror-update-display): Don't indent the first line
of mirror output (meaning no indentation happens if there is a single
line).
* yasnippet-tests.el (single-line-multi-mirror-indentation): New test.
(snippet-with-multiline-mirrors-issue-665): Renamed from
navigate-a-snippet-with-multiline-mirrors-issue-665, test for precise
indentation in addition to navigation (this was already implemented,
contrary to its obsolete docstring).
Fixes #712
---
yasnippet-tests.el | 23 ++++++++++++++++-------
yasnippet.el | 11 +++++++----
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 47b6e1f..8da5f7d 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -227,13 +227,22 @@ end" (buffer-string)))
No indent$>
end" (buffer-string)))))
+(ert-deftest single-line-multi-mirror-indentation ()
+ "Make sure not to indent with multiple mirrors per line."
+ ;; See also Github issue #712.
+ (with-temp-buffer
+ (text-mode)
+ (yas-minor-mode 1)
+ (yas-expand-snippet "${1:XXXXX} --------
+$1 ---------------- $1 ----
+$1 ------------------------")
+ (should (string= (yas--buffer-contents) "XXXXX --------
+XXXXX ---------------- XXXXX ----
+XXXXX ------------------------"))))
-(ert-deftest navigate-a-snippet-with-multiline-mirrors-issue-665 ()
- "In issue 665, a multi-line mirror is attempted.
-Indentation doesn't (yet) happen on these mirrors, but let this
-test guard against any misnavigations that might be introduced by
-an incorrect implementation of mirror auto-indentation"
+(ert-deftest snippet-with-multiline-mirrors-issue-665 ()
+ "In issue 665, a multi-line mirror is attempted."
(with-temp-buffer
(ruby-mode)
(yas-minor-mode 1)
@@ -246,8 +255,8 @@ mapconcat #'(lambda (arg)
(ert-simulate-command '(yas-next-field))
(let ((expected (mapconcat #'identity
'("@bla = bla"
- "[[:blank:address@hidden = ble"
- "[[:blank:address@hidden = bli")
+ " @ble = ble"
+ " @bli = bli")
"\n")))
(should (looking-at expected))
(yas-mock-insert "blo")
diff --git a/yasnippet.el b/yasnippet.el
index 6573f36..57dcdbc 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -4294,10 +4294,13 @@ When multiple expressions are found, only the last one
counts."
(yas--advance-start-maybe (yas--mirror-next mirror) (point))
;; super-special advance
(yas--advance-end-of-parents-maybe mirror-parent-field (point)))
- (let ((yas--inhibit-overlay-hooks t))
- (yas--indent-region (yas--mirror-start mirror)
- (yas--mirror-end mirror)
- snippet)))))
+ (let ((yas--inhibit-overlay-hooks t)
+ (beg (save-excursion (goto-char (yas--mirror-start mirror))
+ (forward-line 1)
+ (point)))
+ (end (yas--mirror-end mirror)))
+ (when (< beg end)
+ (yas--indent-region beg end snippet))))))
(defun yas--field-update-display (field)
"Much like `yas--mirror-update-display', but for fields."
- [elpa] master 85f39ce 06/40: Warn about backquote exprs modifying the buffer, (continued)
- [elpa] master 85f39ce 06/40: Warn about backquote exprs modifying the buffer, Noam Postavsky, 2016/10/26
- [elpa] master e21420a 04/40: Separate parsing from evaluation of backquote lisp, Noam Postavsky, 2016/10/26
- [elpa] master c744148 03/40: Make yas-describe-tables easier to use from lisp, Noam Postavsky, 2016/10/26
- [elpa] master d218ed8 11/40: Do indent the first line of mirrors, but in correct order, Noam Postavsky, 2016/10/26
- [elpa] master 0db65ee 20/40: Don't clobber match data in modification hooks, Noam Postavsky, 2016/10/26
- [elpa] master dc098cf 25/40: Fix yas--message verbosity levels, Noam Postavsky, 2016/10/26
- [elpa] master 5af9276 27/40: Support yas/ symbols in yas-define-menu, Noam Postavsky, 2016/10/26
- [elpa] master ea9581f 22/40: Fix some quoting problems in doc strings, Noam Postavsky, 2016/10/26
- [elpa] master ee6e7a9 09/40: Fix some compilation warnings, Noam Postavsky, 2016/10/26
- [elpa] master 7661dc1 19/40: yasnippet.el (yas-escape-text): No error on nil text, Noam Postavsky, 2016/10/26
- [elpa] master 351c1e3 10/40: Don't indent first line of mirrors,
Noam Postavsky <=
- [elpa] master 655bda8 07/40: Merge: restore backquote evaluation behaviour, Noam Postavsky, 2016/10/26
- [elpa] master 8907fd1 14/40: Escape yas-selected-text for new snippet., Noam Postavsky, 2016/10/26
- [elpa] master a4fafc3 16/40: Add test for loading snippet with same uuid, Noam Postavsky, 2016/10/26
- [elpa] master 8ca8c7d 13/40: Merge: a different fix for #712., Noam Postavsky, 2016/10/26
- [elpa] master 85a43ad 35/40: Explain about backquote expressions in doc, Noam Postavsky, 2016/10/26
- [elpa] master 3129040 24/40: Load snippet after saving, Noam Postavsky, 2016/10/26
- [elpa] master 1532e66 33/40: Fix saving of new snippets, Noam Postavsky, 2016/10/26
- [elpa] master 0ee86a2 23/40: Simplify `yas-new-snippet' load&save logic, Noam Postavsky, 2016/10/26
- [elpa] master 00be21c 36/40: Change cl dep to cl-lib for tests too, Noam Postavsky, 2016/10/26
- [elpa] master 9c9952c 12/40: Add test for indentation of single line mirrors, Noam Postavsky, 2016/10/26