Skip to content

[emacs] Fix single-line-style paragraph fills with code immediately before or after #9600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/etc/emacs/rust-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,35 @@ This is some more text. Fee fie fo fum. Humpty dumpty sat on a wall.
*very very very long string
*/"))

(ert-deftest fill-paragraph-single-line-style-with-code-before ()
(test-fill-paragraph
"fn foo() { }
/// This is my comment. This is more of my comment. This is even more."
"fn foo() { }
/// This is my comment. This is
/// more of my comment. This is
/// even more." 14))

(ert-deftest fill-paragraph-single-line-style-with-code-after ()
(test-fill-paragraph
"/// This is my comment. This is more of my comment. This is even more.
fn foo() { }"
"/// This is my comment. This is
/// more of my comment. This is
/// even more.
fn foo() { }" 1 73))

(ert-deftest fill-paragraph-single-line-style-code-before-and-after ()
(test-fill-paragraph
"fn foo() { }
/// This is my comment. This is more of my comment. This is even more.
fn bar() { }"
"fn foo() { }
/// This is my comment. This is
/// more of my comment. This is
/// even more.
fn bar() { }" 14 67))

(defun test-auto-fill (initial position inserted expected)
(rust-test-manip-code
initial
Expand Down
3 changes: 2 additions & 1 deletion src/etc/emacs/rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@
(let
((fill-paragraph-function
(if (not (eq fill-paragraph-function 'rust-fill-paragraph))
fill-paragraph-function)))
fill-paragraph-function))
(fill-paragraph-handle-comment t))
(apply 'fill-paragraph args)
t))))))

Expand Down