[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8ca8c7d 13/40: Merge: a different fix for #712.
From: |
Noam Postavsky |
Subject: |
[elpa] master 8ca8c7d 13/40: Merge: a different fix for #712. |
Date: |
Wed, 26 Oct 2016 23:06:32 +0000 (UTC) |
branch: master
commit 8ca8c7de4f0f898d4f29af800b83f5e8d79d9a66
Merge: 351c1e3 9c9952c
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Merge: a different fix for #712.
"Don't indent first line of mirrors" had the drawback that sometimes
we *want* to indent the first line of mirrors. So we fix the underlying
problem in a different way and add a test to make sure we don't lose
this behaviour again.
---
yasnippet-tests.el | 11 +++++++++++
yasnippet.el | 17 +++++++++--------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 8da5f7d..1d56fb8 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -240,6 +240,16 @@ $1 ------------------------")
XXXXX ---------------- XXXXX ----
XXXXX ------------------------"))))
+(ert-deftest indent-mirrors-on-update ()
+ "Check that mirrors are always kept indented."
+ (with-temp-buffer
+ (ruby-mode)
+ (yas-minor-mode 1)
+ (yas-expand-snippet "def $1\n$1\nend")
+ (yas-mock-insert "xxx")
+ ;; Assuming 2 space indent.
+ (should (string= "def xxx\n xxx\nend" (buffer-string)))))
+
(ert-deftest snippet-with-multiline-mirrors-issue-665 ()
"In issue 665, a multi-line mirror is attempted."
@@ -255,6 +265,7 @@ mapconcat #'(lambda (arg)
(ert-simulate-command '(yas-next-field))
(let ((expected (mapconcat #'identity
'("@bla = bla"
+ ;; assume ruby is always indented to 2 spaces
" @ble = ble"
" @bli = bli")
"\n")))
diff --git a/yasnippet.el b/yasnippet.el
index 57dcdbc..bfe5590 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -4247,7 +4247,11 @@ When multiple expressions are found, only the last one
counts."
(cl-mapcan #'(lambda (field)
(mapcar #'(lambda (mirror)
(cons field mirror))
- (yas--field-mirrors field)))
+ (cl-sort
+ (cl-copy-list
+ (yas--field-mirrors field))
+ #'<
+ :key #'yas--mirror-start)))
(yas--snippet-fields snippet))
;; then sort this list so that entries with mirrors with parent
;; fields appear before. This was important for fixing #290,
and
@@ -4294,13 +4298,10 @@ 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)
- (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))))))
+ (let ((yas--inhibit-overlay-hooks t))
+ (yas--indent-region (yas--mirror-start mirror)
+ (yas--mirror-end mirror)
+ snippet)))))
(defun yas--field-update-display (field)
"Much like `yas--mirror-update-display', but for fields."
- [elpa] master 0db65ee 20/40: Don't clobber match data in modification hooks, (continued)
- [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, 2016/10/26
- [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 <=
- [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
- [elpa] master 4296a86 15/40: yasnippet.el (yas--quote-string): Remove., Noam Postavsky, 2016/10/26
- [elpa] master d4da806 17/40: Fix removal of snippets by uuid, Noam Postavsky, 2016/10/26
- [elpa] master 42b0c26 18/40: Don't warn about modifications to other buffers, Noam Postavsky, 2016/10/26
- [elpa] master eaaec30 38/40: Replace all occurances of `capitaomorte', Noam Postavsky, 2016/10/26