Skip to content

Commit ed0b390

Browse files
committed
Merge pull request #148 from bmastenbrook/master
Fill regular block comments correctly
2 parents 18fad39 + a8a5e14 commit ed0b390

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

rust-mode-tests.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ Also, the result should be the same regardless of whether the code is at the beg
164164
//
165165
// This is the second really really really really really really long paragraph" 1 89))
166166

167+
(ert-deftest fill-paragraph-multi-line-style-comment ()
168+
(test-fill-paragraph
169+
"/* This is a very very very very very very very very long string
170+
*/"
171+
"/* This is a very very very very
172+
* very very very very long
173+
* string
174+
*/"))
175+
167176
(ert-deftest fill-paragraph-multi-line-style-inner-doc-comment ()
168177
(test-fill-paragraph
169178
"/*! This is a very very very very very very very long string

rust-mode.el

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,10 +1058,18 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
10581058
(let ((result
10591059
;; Replace /* with same number of spaces
10601060
(replace-regexp-in-string
1061-
"\\(?:/\\*+\\)[!*]"
1061+
"\\(?:/\\*+?\\)[!*]?"
10621062
(lambda (s)
1063-
;; We want the * to line up with the first * of the comment start
1064-
(concat (make-string (- (length s) 2) ?\x20) "*"))
1063+
;; We want the * to line up with the first * of the
1064+
;; comment start
1065+
(let ((offset (if (eq t
1066+
(compare-strings "/*" nil nil
1067+
s
1068+
(- (length s) 2)
1069+
(length s)))
1070+
1 2)))
1071+
(concat (make-string (- (length s) offset)
1072+
?\x20) "*")))
10651073
line-start)))
10661074
;; Make sure we've got at least one space at the end
10671075
(if (not (= (aref result (- (length result) 1)) ?\x20))

0 commit comments

Comments
 (0)