Persist highlighting status when changing color schemes #54
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 clear
at the beginning of the color scheme, losing the link between the internal_exchange_region
highlight group and theExchangeRegion
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
andExchangeRegion
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 valueI rejected this approach since it does not honor the user's preference.