add optional clearing of cursorword highlight on leave#35
Open
satorunooshie wants to merge 1 commit intoitchyny:masterfrom
Open
add optional clearing of cursorword highlight on leave#35satorunooshie wants to merge 1 commit intoitchyny:masterfrom
satorunooshie wants to merge 1 commit intoitchyny:masterfrom
Conversation
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.
Summary
This PR adds an optional behavior to clear
CursorWordhighlights whenleaving a window or buffer, and refactors the highlight-clear logic into a
reusable function.
Motivation
When moving between windows or buffers, cursorword highlights can remain
visible in the window you just left, which can be visually noisy. Some users
prefer that highlights are cleared as soon as they leave a window, while
others prefer the current behavior, so this should be configurable.
Changes
Add
cursorword#clear()inautoload/cursorword.vimto:CursorWordmatch (if present).w:cursorword_matchandw:cursorword_state.Refactor the timer-based
cursorword#cursormoved()to callcursorword#clear()instead of duplicating the clear logic inline, keepingits behavior identical to before.
Add a new global option
g:cursorword_clear_on_leave:cursorword#clear()is called onWinLeave,BufLeave.WinLeave,BufLeavedoes nothing and the originalbehavior is preserved.
Keep the non-timer
cursorword#cursormoved()implementation ascall cursorword#matchadd()so there is no behavioral change when timersor
g:cursorword_delaydisable the timer path.Usage
To enable clearing highlights when leaving a window or buffer:
Without this setting, cursorword behaves exactly as before.