about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMicah Chalmer <micah@micahchalmer.net>2013-09-28 17:15:37 -0400
committerMicah Chalmer <micah@micahchalmer.net>2013-09-28 17:40:24 -0400
commit5d24a1ae45189b8222ce84084eaae3ff8b7d67d0 (patch)
tree818861c7825a5c01896a200e6f7e890a69404fcd
parentc635fba748ace3ad08b97d9ca53366dadabf2028 (diff)
downloadrust-5d24a1ae45189b8222ce84084eaae3ff8b7d67d0.tar.gz
rust-5d24a1ae45189b8222ce84084eaae3ff8b7d67d0.zip
Fix single-line-style paragraph fills with code immediately before or after
-rw-r--r--src/etc/emacs/rust-mode-tests.el29
-rw-r--r--src/etc/emacs/rust-mode.el3
2 files changed, 31 insertions, 1 deletions
diff --git a/src/etc/emacs/rust-mode-tests.el b/src/etc/emacs/rust-mode-tests.el
index 4bfdee50c6b..67e779e220f 100644
--- a/src/etc/emacs/rust-mode-tests.el
+++ b/src/etc/emacs/rust-mode-tests.el
@@ -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
diff --git a/src/etc/emacs/rust-mode.el b/src/etc/emacs/rust-mode.el
index bad1ea510be..a3b75815718 100644
--- a/src/etc/emacs/rust-mode.el
+++ b/src/etc/emacs/rust-mode.el
@@ -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))))))