vim-exchange icon indicating copy to clipboard operation
vim-exchange copied to clipboard

Persist highlighting status when changing color schemes

Open jchros opened this issue 5 years ago • 0 comments

Before #53, the highlighting of exchange regions was lost when the color scheme is changed, ignoring the user's preference; this bug was caused by the execution of :highlight clear at the beginning of the color scheme, losing the link between the internal _exchange_region highlight group and the ExchangeRegion group. #53 fixed this bug by defaulting the link, making it resilient to color scheme changes.

However, this fix introduced the opposite bug; when changing the color scheme, the highlighting of exchange regions is always enabled, regardless of the user's preference, and :XchangeHighlightToggle fails to disable it, as demonstrated in the video below:

https://user-images.githubusercontent.com/28897513/102714182-39c6f080-42cd-11eb-816a-00a68bc1f4ef.mov

In this pull request, these issues are fixed by adding an autocmd restoring the link between _exchange_region and ExchangeRegion every time the color scheme changes if the highlighting is enabled.

The changes introduced in #53 are reverted, since they conflict with those introduced by this fix.

A follow-up on #52.

Alternatives considered

Toggle highlighting twice

While simpler than the changes introduced in this pull request, I rejected this approach because it feels like a hack to me.

Keep existing behavior, but set s:enable_highlighting to a true value

I rejected this approach since it does not honor the user's preference.

jchros avatar Dec 20 '20 17:12 jchros