For a new filetype, I was trying to make block comments in the syntax highlighting but they kept disappearing while I was moving around. I have managed to reduce it to the following. First, in the syntax file, there is just this:
syn region testComment start=/a/ end=/b/
hi def link testComment Comment
In my file created to highlight (pun not intended) the problem, I have this:
According to the rule, the entire file should be colored like a comment, and it does normally. However, when moving the cursor down through the whole file while staying on the first column, once I hit the final set of parentheses, the last three visible characters ('
)', and '
b') are un-colored. This can be fixed in the moment by redrawing the screen.
I noticed that the
matchparen plugin is involved. While moving the cursor down, the first set of parentheses is matched correctly, the second set is not matched, and then when the third set should be matched is when the color goes off. Disabling the plugin through
:NoMatchParen makes the problem not appear.
Several things cause the problem not to happen. If I remove the empty line it works. If I go to the second opening parenthesis on the way down it works. If I remove the empty line but add an extra space before the second close parenthesis, the problem comes back. It seems like the plugin has a hard time reading the second set of parentheses and then freaks out on the third one.
I am pretty sure this is a bug in the matchparen plugin. However, block comments work just fine in other languages, like C. So, my final question is this: How can I change my syntax file to make this problem not happen, maybe similarly to how C does it?
I have Vim 8.1.