-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spurious highlight when using match on character at end of soft-wrapped line #9242
Comments
The patch 8.2.3698 fixed the issue for a highlight installed by a match, but not for a highlight installed by a text property: vim9script
&l:breakindent = true
&l:linebreak = true
set breakat+=]
printf('%s]%s[xxx]%s', repeat('x', 70), repeat('x', 50), repeat('x', 70))
->setline(1)
normal! 6e
prop_type_add('test', {highlight: 'ErrorMsg'})
prop_add(1, 126, {length: 1, type: 'test'}) In practice, this means that the Vim9 refactoring is still affected by the issue, because it uses text properties. |
Problem: Text property highlighting continues over breakindent. Solution: Stop before the end column. (closes #9242)
The patch 8.2.3700 fixed the second issue, but it created a third one which is worse because it occurs much more frequently: vim9script
&l:linebreak = true
"\t[xxx]"->setline(1)
prop_type_add('test', {highlight: 'ErrorMsg'})
prop_add(1, 2, {length: 1, type: 'test'}) Notice that all the cells covered by the tab character are highlighted, because it's in front of the opening bracket. Before the patch, only the bracket was highlighted. I have no idea why If it can't be fixed, I think it would be better to simply revert the patch, because it makes the matchparen refactoring much worse. This is especially noticeable when reading Vim's help pages, where lines are indented with tabs, and often start with brackets. |
Problem: Text property highlighting is used on Tab. Solution: Only set in_linebreak when not on a Tab. (closes #9242)
The patch 8.2.3700 introduced a regression: vim9script
&linebreak = true
&wrap = true
printf('%s+(%s)', 'x'->repeat(&columns / 2), 'x'->repeat(&columns / 2))->setline(1)
prop_type_add('test', {highlight: 'ErrorMsg'})
prop_add(1, (&columns / 2) + 2, {length: 1, type: 'test'}) Notice that all the empty cells after the |
Problem: When using 'linebreak' a text property starts too early. Solution: Decrement "bcol" when looking for property start. (closes #9242)
Not sure whether it's the same issue, but here is another case where some cells are highlighted even though they are not occupied by any character in the buffer: vim9script
printf('%s (:%s)', 'x'->repeat(&columns / 2), 'y'->repeat(&columns / 2))
->setline(1)
&linebreak = true
matchadd('ErrorMsg', '([^)]*)') Notice that, on the first line of the screen, every cell after the colon is highlighted. But none of them is occupied by a character. Same behavior with a syntax rule: vim9script
printf('%s (:%s)', 'x'->repeat(&columns / 2), 'y'->repeat(&columns / 2))
->setline(1)
&linebreak = true
syntax on
syntax match Test /([^)]*)/
highlight link Test ErrorMsg Same behavior with a text property: vim9script
printf('%s (:%s)', 'x'->repeat(&columns / 2), 'y'->repeat(&columns / 2))
->setline(1)
&linebreak = true
prop_type_add('Test', {highlight: 'ErrorMsg'})
prop_add(1, searchpos('(', 'nW')[1], {length: getline(1)->strlen(), type: 'Test'}) As a workaround, we need to invoke vim9script
printf('%s (:%s)', 'x'->repeat(&columns / 2), 'y'->repeat(&columns / 2))
->setline(1)
&linebreak = true
for col: number in range(searchpos('(', 'nW')[1], getline(1)->strlen())
matchaddpos('ErrorMsg', [[1, col]])
endfor |
Problem: Match highlighting continues over breakindent. Solution: Stop before the end column. (closes vim/vim#9242) vim/vim@0c359af Cherry-pick Test_matchdelete_redraw() from patch 8.2.1077. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Match highlighting continues over breakindent. Solution: Stop before the end column. (closes vim/vim#9242) vim/vim@0c359af Cherry-pick Test_matchdelete_redraw() from patch 8.2.1077. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Match highlighting continues over breakindent. Solution: Stop before the end column. (closes vim/vim#9242) vim/vim@0c359af Cherry-pick Test_matchdelete_redraw() from patch 8.2.1077. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Steps to reproduce
Run this shell command:
Notice that on the second soft-wrapped line, the highlight is applied from the cell occupied by the last character, up to the very last cell of the window.
Expected behavior
Maybe it's working as intended, but I think it's still distracting and misleading for the user. There are no real characters on the cells after the last
]
.Shouldn't the highlight be applied only on the cell whose coordinates were passed to
matchaddpos()
? That is:And not:
Operating system
Ubuntu 20.04.3 LTS
Version of Vim
8.2 Included patches: 1-3692
Screenshot
Additional Context
I found this issue while using the matchparen plugin:
Same issue with a text property:
The text was updated successfully, but these errors were encountered: