Skip to content

Commit 5d24a1a

Browse files
committed
Fix single-line-style paragraph fills with code immediately before or after
1 parent c635fba commit 5d24a1a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

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

+29
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,35 @@ This is some more text. Fee fie fo fum. Humpty dumpty sat on a wall.
196196
*very very very long string
197197
*/"))
198198

199+
(ert-deftest fill-paragraph-single-line-style-with-code-before ()
200+
(test-fill-paragraph
201+
"fn foo() { }
202+
/// This is my comment. This is more of my comment. This is even more."
203+
"fn foo() { }
204+
/// This is my comment. This is
205+
/// more of my comment. This is
206+
/// even more." 14))
207+
208+
(ert-deftest fill-paragraph-single-line-style-with-code-after ()
209+
(test-fill-paragraph
210+
"/// This is my comment. This is more of my comment. This is even more.
211+
fn foo() { }"
212+
"/// This is my comment. This is
213+
/// more of my comment. This is
214+
/// even more.
215+
fn foo() { }" 1 73))
216+
217+
(ert-deftest fill-paragraph-single-line-style-code-before-and-after ()
218+
(test-fill-paragraph
219+
"fn foo() { }
220+
/// This is my comment. This is more of my comment. This is even more.
221+
fn bar() { }"
222+
"fn foo() { }
223+
/// This is my comment. This is
224+
/// more of my comment. This is
225+
/// even more.
226+
fn bar() { }" 14 67))
227+
199228
(defun test-auto-fill (initial position inserted expected)
200229
(rust-test-manip-code
201230
initial

src/etc/emacs/rust-mode.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@
300300
(let
301301
((fill-paragraph-function
302302
(if (not (eq fill-paragraph-function 'rust-fill-paragraph))
303-
fill-paragraph-function)))
303+
fill-paragraph-function))
304+
(fill-paragraph-handle-comment t))
304305
(apply 'fill-paragraph args)
305306
t))))))
306307

0 commit comments

Comments
 (0)