Fix c-ts-common filling function (bug#71760)

* lisp/progmodes/c-ts-common.el (c-ts-common--fill-block-comment): If
masking hasn't been done, don't unmask.
This commit is contained in:
Damien Cassou 2024-07-21 21:33:59 +02:00 committed by Yuan Fu
parent e50d597f45
commit 292fcd2009
No known key found for this signature in database
GPG key ID: 56E19BC57664A442

View file

@ -151,7 +151,9 @@ comment."
(orig-point (point-marker))
(start-marker (point-marker))
(end-marker nil)
(end-len 0))
(end-len 0)
(start-mask-done nil)
(end-mask-done nil))
(move-marker start-marker start)
;; We mask "/*" and the space before "*/" like
;; `c-fill-paragraph' does.
@ -162,6 +164,7 @@ comment."
(group "/") "*"))
(goto-char (match-beginning 1))
(move-marker start-marker (point))
(setq start-mask-done t)
(replace-match " " nil nil nil 1))
;; Include whitespaces before /*.
@ -179,6 +182,7 @@ comment."
(goto-char (match-beginning 1))
(setq end-marker (point-marker))
(setq end-len (- (match-end 1) (match-beginning 1)))
(setq end-mask-done t)
(replace-match (make-string end-len ?x)
nil nil nil 1))
@ -206,11 +210,11 @@ comment."
(fill-region (max start-marker para-start) (min end para-end) arg))
;; Unmask.
(when start-marker
(when (and start-mask-done start-marker)
(goto-char start-marker)
(delete-char 1)
(insert "/"))
(when end-marker
(when (and end-mask-done start-marker)
(goto-char end-marker)
(delete-region (point) (+ end-len (point)))
(insert (make-string end-len ?\s)))