summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-12-03 09:32:38 -0500
committerNiko Matsakis <niko@alum.mit.edu>2015-12-03 09:32:38 -0500
commit95d089cbc3a23c0dd23869e716520c31daefdf8f (patch)
tree6ea3ddad982ab9ba19fc1fa10f3c791d7c198d2b
parenteaf95af109b2f90441fb4976678b1f058d2c4de8 (diff)
parenta33b684a027b8f5efb1e197d7f3e294d2f271f26 (diff)
downloadrust-mode-95d089cbc3a23c0dd23869e716520c31daefdf8f.tar.gz
Merge pull request #110 from mrBliss/fix-103
Fix #103
-rw-r--r--rust-mode-tests.el18
-rw-r--r--rust-mode.el4
2 files changed, 21 insertions, 1 deletions
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)