Skip to content

Commit 92584c3

Browse files
committed
Fix the special case for the first line
This special case broke indentation of `where` clauses.
1 parent b76e803 commit 92584c3

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

rust-mode-tests.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,17 @@ impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap<K, V, S>
603603
}
604604
"))
605605

606+
(ert-deftest indent-align-where-clauses-first-line ()
607+
(test-indent
608+
"fn foo1(a: A, b: B) -> A
609+
where A: Clone + Default, B: Eq {
610+
let body;
611+
Foo {
612+
bar: 3
613+
}
614+
}
615+
"))
616+
606617
(ert-deftest indent-square-bracket-alignment ()
607618
(test-indent
608619
"

rust-mode.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,11 @@ function or trait. When nil, where will be aligned with fn or trait."
444444

445445
(save-excursion
446446
(rust-rewind-irrelevant)
447-
;; Point is now at the end of the previous ine
447+
;; Point is now at the end of the previous line
448448
(or
449-
;; If we are at the first line, no indentation is needed, so stay at baseline...
450-
(= 1 (line-number-at-pos (point)))
449+
;; If we are at the start of the buffer, no
450+
;; indentation is needed, so stay at baseline...
451+
(= (point) 1)
451452
;; ..or if the previous line ends with any of these:
452453
;; { ? : ( , ; [ }
453454
;; then we are at the beginning of an expression, so stay on the baseline...

0 commit comments

Comments
 (0)