Skip to content

Commit a469734

Browse files
committed
Cover all cases for padding in paragraph fills as intended
1 parent be4f19a commit a469734

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,25 @@ Also, the result should be the same regardless of whether the code is at the beg
5151
(padding-len (length padding)))
5252
(loop
5353
for pad-at-beginning from 0 to 1
54-
for pad-at-end from 0 to 1
55-
with padding-beginning = (if (= 0 pad-at-beginning) "" padding)
56-
with padding-end = (if (= 0 pad-at-end) "" padding)
57-
with padding-adjust = (* padding-len pad-at-beginning)
58-
with padding-beginning = (if (= 0 pad-at-beginning) "" padding)
59-
with padding-end = (if (= 0 pad-at-end) "" padding)
60-
for pos from (if (= 1 start-pos) 1 (+ padding-adjust start-pos)) to (+ end-pos padding-adjust)
61-
do (rust-test-manip-code
62-
(concat padding-beginning unfilled padding-end)
63-
pos
64-
(lambda ()
65-
(let ((fill-column rust-test-fill-column))
66-
(fill-paragraph)))
67-
(concat padding-beginning expected padding-end)))))
54+
do (loop for pad-at-end from 0 to 1
55+
with padding-beginning = (if (= 0 pad-at-beginning) "" padding)
56+
with padding-end = (if (= 0 pad-at-end) "" padding)
57+
with padding-adjust = (* padding-len pad-at-beginning)
58+
with padding-beginning = (if (= 0 pad-at-beginning) "" padding)
59+
with padding-end = (if (= 0 pad-at-end) "" padding)
60+
;; If we're adding space to the beginning, and our start position
61+
;; is at the very beginning, we want to test within the added space.
62+
;; Otherwise adjust the start and end for the beginning padding.
63+
with start-pos = (if (= 1 start-pos) 1 (+ padding-adjust start-pos))
64+
with end-pos = (+ end-pos padding-adjust)
65+
do (loop for pos from start-pos to end-pos
66+
do (rust-test-manip-code
67+
(concat padding-beginning unfilled padding-end)
68+
pos
69+
(lambda ()
70+
(let ((fill-column rust-test-fill-column))
71+
(fill-paragraph)))
72+
(concat padding-beginning expected padding-end)))))))
6873

6974
(ert-deftest fill-paragraph-top-level-multi-line-style-doc-comment-second-line ()
7075
(test-fill-paragraph

0 commit comments

Comments
 (0)