summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-04-12 15:43:31 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-04-12 15:43:31 -0400
commited0b390e11be6642085ae05a57aa9ceae63211c4 (patch)
tree97b301c8a407e0640eab81e4062f5caf2c11887a
parent18fad391b9ab1dd4eb060fe076a1c2712dc30330 (diff)
parenta8a5e14544ce3cf9fb9319ece667f8dbe27c1034 (diff)
downloadrust-mode-ed0b390e11be6642085ae05a57aa9ceae63211c4.tar.gz
Merge pull request #148 from bmastenbrook/master
Fill regular block comments correctly
-rw-r--r--rust-mode-tests.el9
-rw-r--r--rust-mode.el14
2 files changed, 20 insertions, 3 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 2c0431c..de3900c 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -164,6 +164,15 @@ Also, the result should be the same regardless of whether the code is at the beg
//
// This is the second really really really really really really long paragraph" 1 89))
+(ert-deftest fill-paragraph-multi-line-style-comment ()
+ (test-fill-paragraph
+ "/* This is a very very very very very very very very long string
+ */"
+ "/* This is a very very very very
+ * very very very very long
+ * string
+ */"))
+
(ert-deftest fill-paragraph-multi-line-style-inner-doc-comment ()
(test-fill-paragraph
"/*! This is a very very very very very very very long string
diff --git a/rust-mode.el b/rust-mode.el
index 62d3007..647e6b1 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1058,10 +1058,18 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
(let ((result
;; Replace /* with same number of spaces
(replace-regexp-in-string
- "\\(?:/\\*+\\)[!*]"
+ "\\(?:/\\*+?\\)[!*]?"
(lambda (s)
- ;; We want the * to line up with the first * of the comment start
- (concat (make-string (- (length s) 2) ?\x20) "*"))
+ ;; We want the * to line up with the first * of the
+ ;; comment start
+ (let ((offset (if (eq t
+ (compare-strings "/*" nil nil
+ s
+ (- (length s) 2)
+ (length s)))
+ 1 2)))
+ (concat (make-string (- (length s) offset)
+ ?\x20) "*")))
line-start)))
;; Make sure we've got at least one space at the end
(if (not (= (aref result (- (length result) 1)) ?\x20))