Skip to content

Commit 5e032a2

Browse files
MicahChalmeralexcrichton
authored andcommitted
---
yaml --- r: 105278 b: refs/heads/master c: d28d5b7 h: refs/heads/master v: v3
1 parent 45778c5 commit 5e032a2

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: aac6e317639140a149d97116d43e66b5bd76bce3
2+
refs/heads/master: d28d5b7fb4ee11d29260b477b70ac32c25f61cff
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
55
refs/heads/try: db814977d07bd798feb24f6b74c00800ef458a13

trunk/src/etc/emacs/rust-mode-tests.el

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,11 @@ fn indenting_middle_of_line() {
570570
pull_me_back_in();
571571
}
572572
}
573+
574+
fn indented_already() {
575+
576+
// The previous line already has its spaces
577+
}
573578
"
574579

575580
;; Symbol -> (line column)
@@ -596,7 +601,15 @@ fn indenting_middle_of_line() {
596601
(after-whitespace-indent-start (13 1))
597602
(after-whitespace-indent-target (13 8))
598603
(middle-pull-indent-start (15 19))
599-
(middle-pull-indent-target (15 12))))
604+
(middle-pull-indent-target (15 12))
605+
(blank-line-indented-already-bol-start (20 0))
606+
(blank-line-indented-already-bol-target (20 4))
607+
(blank-line-indented-already-middle-start (20 2))
608+
(blank-line-indented-already-middle-target (20 4))
609+
(nonblank-line-indented-already-bol-start (21 0))
610+
(nonblank-line-indented-already-bol-target (21 4))
611+
(nonblank-line-indented-already-middle-start (21 2))
612+
(nonblank-line-indented-already-middle-target (21 4))))
600613

601614
(defun rust-get-buffer-pos (pos-symbol)
602615
"Get buffer position from POS-SYMBOL.
@@ -793,3 +806,31 @@ All positions are position symbols found in `rust-test-positions-alist'."
793806
'middle-pull-indent-start
794807
'middle-pull-indent-target
795808
#'indent-for-tab-command))
809+
810+
(ert-deftest indent-line-blank-line-indented-already-bol ()
811+
(rust-test-motion
812+
rust-test-indent-motion-string
813+
'blank-line-indented-already-bol-start
814+
'blank-line-indented-already-bol-target
815+
#'indent-for-tab-command))
816+
817+
(ert-deftest indent-line-blank-line-indented-already-middle ()
818+
(rust-test-motion
819+
rust-test-indent-motion-string
820+
'blank-line-indented-already-middle-start
821+
'blank-line-indented-already-middle-target
822+
#'indent-for-tab-command))
823+
824+
(ert-deftest indent-line-nonblank-line-indented-already-bol ()
825+
(rust-test-motion
826+
rust-test-indent-motion-string
827+
'nonblank-line-indented-already-bol-start
828+
'nonblank-line-indented-already-bol-target
829+
#'indent-for-tab-command))
830+
831+
(ert-deftest indent-line-nonblank-line-indented-already-middle ()
832+
(rust-test-motion
833+
rust-test-indent-motion-string
834+
'nonblank-line-indented-already-middle-start
835+
'nonblank-line-indented-already-middle-target
836+
#'indent-for-tab-command))

trunk/src/etc/emacs/rust-mode.el

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@
140140
;; Otherwise, we are continuing the same expression from the previous line,
141141
;; so add one additional indent level
142142
(+ baseline rust-indent-offset))))))))))
143-
(when (not (eq (current-indentation) indent))
144-
;; If we're at the beginning of the line (before or at the current
145-
;; indentation), jump with the indentation change. Otherwise, save the
146-
;; excursion so that adding the indentations will leave us at the
147-
;; equivalent position within the line to where we were before.
148-
(if (<= (current-column) (current-indentation))
149-
(indent-line-to indent)
150-
(save-excursion (indent-line-to indent))))))
143+
144+
;; If we're at the beginning of the line (before or at the current
145+
;; indentation), jump with the indentation change. Otherwise, save the
146+
;; excursion so that adding the indentations will leave us at the
147+
;; equivalent position within the line to where we were before.
148+
(if (<= (current-column) (current-indentation))
149+
(indent-line-to indent)
150+
(save-excursion (indent-line-to indent)))))
151151

152152

153153
;; Font-locking definitions and helpers

0 commit comments

Comments
 (0)