Persist highlighting status when changing color schemes#54
Open
jchros wants to merge 3 commits intotommcdo:masterfrom
Open
Persist highlighting status when changing color schemes#54jchros wants to merge 3 commits intotommcdo:masterfrom
jchros wants to merge 3 commits intotommcdo:masterfrom
Conversation
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.
The warning appeared when disabling the highlighting of exchange regions.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 clearat the beginning of the color scheme, losing the link between the internal_exchange_regionhighlight group and theExchangeRegiongroup. #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
:XchangeHighlightTogglefails to disable it, as demonstrated in the video below:test1.mov
In this pull request, these issues are fixed by adding an
autocmdrestoring the link between_exchange_regionandExchangeRegionevery 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_highlightingto a true valueI rejected this approach since it does not honor the user's preference.