emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode 95d089c 211/486: Merge pull request #110 from mr


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode 95d089c 211/486: Merge pull request #110 from mrBliss/fix-103
Date: Sat, 7 Aug 2021 09:25:20 -0400 (EDT)

branch: elpa/rust-mode
commit 95d089cbc3a23c0dd23869e716520c31daefdf8f
Merge: eaf95af a33b684
Author: Niko Matsakis <niko@alum.mit.edu>
Commit: Niko Matsakis <niko@alum.mit.edu>

    Merge pull request #110 from mrBliss/fix-103
    
    Fix #103
---
 rust-mode-tests.el | 18 ++++++++++++++++++
 rust-mode.el       |  4 +++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index cc76007..cbfde96 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -771,6 +771,24 @@ fn foo() {
 "
    ))
 
+;; This is a test for #103: a comment after the last struct member that does
+;; not have a trailing comma. The comment used to be indented one stop too
+;; far.
+(ert-deftest indent-comment-after-last-struct-member ()
+  (test-indent
+   "
+struct A {
+    x: u8
+    // comment
+}
+
+struct A {
+    x: u8
+    /* comment */
+}
+"
+   ))
+
 (setq rust-test-motion-string
       "
 fn fn1(arg: int) -> bool {
diff --git a/rust-mode.el b/rust-mode.el
index 6b09580..1d39a54 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -440,7 +440,9 @@ function or trait.  When nil, where will be aligned with fn 
or trait."
                        ;; baseline as well (we are continuing an expression,
                        ;; but the "else" or "{" should align with the beginning
                        ;; of the expression it's in.)
-                       (looking-at "\\<else\\>\\|{")
+                       ;; Or, if this line starts a comment, stay on the
+                       ;; baseline as well.
+                       (looking-at "\\<else\\>\\|{\\|/[/*]")
 
                        (save-excursion
                          (rust-rewind-irrelevant)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]