-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Make listchar override cursorline in highlight #4744
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
Conversation
Thanks a lot.
Please leave a comment if you update the PR, so we don't miss it. |
7554901
to
0746607
Compare
I fixed these 3 test errors, in which the listchars should override visual mode highlight. |
8b870a8
to
2f93b42
Compare
I found that there is not lua test coverage on |
Any suggestions? |
@zhou13 It is always better to add test for the functionality that is not tested then not to add it. Neither Neovim complete test suite nor old Vim functional tests cover present functionality completely. But in addition to this Vim does not have framework for testing visual features, only having a few functions that may sometimes help, but are not as convenient. |
I added two tests for cursorline/listchars and I fixed the lint warning. |
I like this improvement, but there's inconsistency:
It's arguable that visual-selection should use listchars-highlight for precedes/extends, but OTOH it departs from Vim and it makes it unclear where the selection starts and ends (which is why Vim behaves this way). So let's keep the Vim behavior for visual-selection. |
[2] = {bold = true}, | ||
[3] = { | ||
foreground = hlgroup_colors.NonText, | ||
background = hlgroup_colors.Visual, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test changes should be reverted. The change should only affect cursorline, not visual-selection. (I don't see anywhere in mouse_spec.lua
where cursorline
is set.)
@justinmk Hi justinmk, thanks for pointing out the inconsistency problem in visual selection. IMO, I think the "correct" behavior should be
This is because the former listchar represents a real character and the latter represents the continuity of a line. For the former one, the benefit is that now I can distinguish between Also, I observed that |
Yeah, but the problem is that any of those chars may exist at the start/end of a line, thus causing confusion.
I'm not much worried about Vim-compat here, but I am very worried about making a change that is not a net improvement. In other words, if we make a change that has some pros and cons, and we choose the inverse of those pros and cons, we didn't really gain a net improvement. And I have a feeling we'll get lots of complaints about this and won't be able to defend it. |
Could you make an example to explain why it will cause the confusion in visual mode? |
Where
If the visual-selection bg color appears behind the |
TBH even highlighting |
The default behavior of vim won't highlight extends and precedes with visual-selection bg, so I think we can just keep these behavior. But we should highlight eol tab trail nbsp space in visual selection using listchar. If you do not specify This is the current effect after this patch: So I think the only thing needs to be fixed is the highlight space listchar under visual selection. |
Also nbsp, if I'm not mistaken. |
I think I fixed all the known issues. Please review. |
Merged after rebase. |
With this PR, the highlight of cursorline and cursorcolumn can work with
list/listchar better. Put the following in your vim setting:
and put your cursor in the first line while view the file with following content:
Before the patch:
http://imgur.com/E2vPlWp
After the patch:
http://imgur.com/cn6lj12
Notice the difference in the color of space, tab, and eol symbol. This should
fix Issue #3670.