Skip to content
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

Persist highlighting status when changing color schemes #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jchros
Copy link
Contributor

@jchros jchros commented Dec 20, 2020

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:

test1.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.

Well-written Vim color schemes run the command :highlight clear to
remove the highlight groups set by a previous color scheme.
Unfortunately, this also removes the internal highlight group set by
vim-exchange, effectively disabling vim-exchange's highlighting, and
running :XchangeHighlightToggle does not reenable the plugin's
highlighting.

In this commit, this is fixed by adding an autocmd to link the
_exchange_region highlight group back to ExchangeRegion when the color
scheme is changed and the highlighting is enabled.
This reverts commit 17f1a2c, reversing
changes made to 13d3895.
The warning appeared when disabling the highlighting of exchange
regions.
@jchros jchros marked this pull request as ready for review December 20, 2020 17:57
jchros added a commit to jchros/vimfiles that referenced this pull request Feb 18, 2021
It fixes a bug regarding syntax highlighting on colorscheme change; see
tommcdo/vim-exchange#54.
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.

None yet

1 participant