tpope / vim-commentary

commentary.vim: comment stuff out
http://www.vim.org/scripts/script.php?script_id=3695
5.9k stars 214 forks source link

Comments with no space turn open parens into unmatched comments #121

Open whonore opened 4 years ago

whonore commented 4 years ago

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.

tpope commented 4 years ago

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

whonore commented 4 years ago

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.