Skip to content

Conversation

@glepnir
Copy link
Member

@glepnir glepnir commented Aug 30, 2025

Problem: Listchars aintain their SpecialKey highlighting when within a visual selection, unlike regular text which adopts Visual highlighting.

Solution: Remove attr_pri restriction in attribute combination logic to allow listchars display in visual mode, combining extra_attr with existing char_attr when visual selection is active.

relate neovim/neovim#34189

@glepnir glepnir marked this pull request as draft August 30, 2025 06:42
Problem: Listchars aintain their SpecialKey highlighting when within
a visual selection, unlike regular text which adopts Visual highlighting.

Solution: Remove attr_pri restriction in attribute combination logic to
allow listchars display in visual mode, combining extra_attr with existing
char_attr when visual selection is active.
@glepnir glepnir marked this pull request as ready for review August 30, 2025 09:12
@habamax

This comment was marked as off-topic.

@glepnir glepnir changed the title Allow listchars to inherit visual selection highlighting feat: listchars only in visual mode Sep 1, 2025
@glepnir glepnir marked this pull request as draft September 1, 2025 10:14
@glepnir
Copy link
Member Author

glepnir commented Sep 1, 2025

Yes. The previous change altered the merge priority. The original issue has been updated to request supporting listchars only when in Visual mode. Currently, a new option visuallist has been added (a better name would be welcome) that shows the selected area's listchars only when in Visual mode, using the VisualSpecialKey highlight group. Sorry, I collapsed your comment — there were a bit too many images, which made browsing here quite lengthy.. there are some uncertain parts… I might need you to take a look and help @zeertzjq

@zeertzjq
Copy link
Member

zeertzjq commented Sep 1, 2025

'listchars' are only displayed during Visual mode within the selected area

This will complicate the size computation of TABs and the cursor positioning on TABs, as they depend on whether 'list' and 'listchars' tab field are used, and with this 'visuallist' they'll have to depend on whether the TAB is in the Visual selection as well. And if the (blockwise) Visual selection only covers a part of a TAB, things may get even more complicated.

@glepnir
Copy link
Member Author

glepnir commented Sep 1, 2025

your reply was so fast that I hadn’t refreshed the page yet. Wouldn’t it be enough to just control a variable and attribute for whether to render listchars? No other calculations need to be changed.

@zeertzjq
Copy link
Member

zeertzjq commented Sep 1, 2025

Wouldn’t it be enough to just control a variable and attribute for whether to render listchars?

No. Because

  1. If 'list' is set and tab isn't present in 'listchars', a TAB is rendered as ^I or <09>.
  2. If 'list' is set, cursor is placed on the first cell on the TAB, otherwise it's placed on the last cell.

So if you change whether 'list' is applied to depend on the Visual selection, these will have to depend on the Visual selection as well.

@habamax
Copy link
Contributor

habamax commented Sep 1, 2025

'listchars' are only displayed during Visual mode within the selected area

This will complicate the size computation of TABs and the cursor positioning on TABs, as they depend on whether 'list' and 'listchars' tab field are used, and with this 'visuallist' they'll have to depend on whether the TAB is in the Visual selection as well. And if the (blockwise) Visual selection only covers a part of a TAB, things may get even more complicated.

That is what I was thinking looking at the updated docs here in PR.

What would happen to those partial tabs in blockwise selection?
image

@glepnir
Copy link
Member Author

glepnir commented Sep 1, 2025

Thanks. I’ll try these cases ..

@chrisbra
Copy link
Member

chrisbra commented Sep 1, 2025

Isn't this something that could be achieved using a ModeChanged autocommand?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants