Describe the bug
When using set cursorline with cursorlineopt set to either both, line, or screenline, an extra column will be highlighted on the cursor's line when using matchadd() to highlight multiple lines. The problem does not occur when set cursorline is used with set cursorlineopt=number.
To Reproduce
Good behavior (without set cursorline):
Run vim --clean
Insert a few lines of text into the buffer.
:call matchadd('Visual', '\_.*'). Result:
Bad behavior (with set cursorline):
Run vim --clean
:set cursorline
Insert a few lines of text into the buffer.
Position the cursor on the first line of the buffer and :call matchadd('Visual', '\_.*'). Result:
Exit Vim, repeat steps 1-3, position the cursor on the second line of the buffer and :call matchadd('Visual', '\_.*'). Result:
Notice how an extra column is highlighted at the end of the cursor's line.
Expected behavior
There should be no extra highlighted column at the end of the cursor's line.
Environment (please complete the following information):
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
Interestingly, when matching with ".*" then it's the other way around, at the cursor line the last character is not highlighted.
I would argue that searching for "_." includes the line separator, thus highlighting the extra character would be correct. Thus the highlight in the cursor line is OK. Other lines stop too early.
"." actually does not include the line separator, but after matching the whole line of text there is an empty match at the end of the line, and for an empty match one character extra is highlighted. ".+" does not have the extra match. I managed to fix that part, the other one is not so easy.