vim-commentary icon indicating copy to clipboard operation
vim-commentary copied to clipboard

Comments with no space turn open parens into unmatched comments

Open whonore opened this issue 5 years ago • 2 comments

Given an ML-like language with commentstring=(*%s*), taking the valid program:

(**)
val x = (
  1)

and selecting it all and commenting with gc gives:

(*(**)*)
(*val  x = (*)
(*  1)*)

The (*) on the second line is then treated as an unmatched open comment.

The cause of this bug is probably the same as in some past issues (#3, #29, #40, etc), but the fix might be simpler here since you'd just need to ensure that there's always a space between the last character in a line and the closing comment.

whonore avatar Jan 26 '20 16:01 whonore

We already do ensure there's a space. Do you have b:commentary_format set?

tpope avatar Jan 26 '20 16:01 tpope

No, b:commentary_format is unset, commentstring=(*%s*), comments=sr:(*,mb:*,ex:*). Commenting the second line by itself adds a space, but any range including the (**) line does not.

whonore avatar Jan 26 '20 18:01 whonore