fix(highlight): make intra-line bg visible under line backgrounds (#192)#194
Merged
barrettruth merged 3 commits intomainfrom Mar 15, 2026
Merged
fix(highlight): make intra-line bg visible under line backgrounds (#192)#194barrettruth merged 3 commits intomainfrom
barrettruth merged 3 commits intomainfrom
Conversation
…n clearing Problem: single-row extmarks (`end_row = buf_line, end_col = len`) do not trigger `hl_eol` — Neovim requires `end_row > start_row`. Line backgrounds stopped at the last character instead of extending to the window edge. Solution: use `end_row = buf_line + 1, end_col = 0` for line bg extmarks. Replace per-hunk `nvim_buf_clear_namespace` with `clear_ns_by_start` that queries extmarks by start position only, so adjacent hunks' trailing `end_row` is never killed.
Problem: when fugitive collapses a diff section, Neovim repositions extmarks from deleted lines onto surviving lines. `carry_forward_highlighted` matched hunks by content only, carrying forward the "highlighted" flag for stable hunks and leaving stale extmarks from removed hunks uncleaned. Solution: add `#entry.hunks == #hunks` guard to the carry-forward precondition. When hunk count changes, skip carry-forward and set `pending_clear = true` so `on_buf` wipes all extmarks before `on_win` re-highlights visible hunks.
60785c3 to
aeb74e0
Compare
Owner
Author
|
@phanen take latest main and let me know if this fixes it. |
|
Ok, it did fix. Thanks a lot for your efforts. |
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.
Problem
line_hl_groupbg unconditionally overrideshl_groupbg regardless of priority (neovim/neovim#31151).DiffsAddText/DiffsDeleteTextintra-line highlights at p201 were invisible underDiffsAdd/DiffsDeleteline backgrounds at p200 because they operate on separate Neovim stacking layers.Solution
Replace
line_hl_groupwithhl_group+hl_eolfor line backgrounds, putting them on the same layer as intra-line highlights so priority stacking works. Use multiline extmarks (end_row = buf_line + 1, end_col = 0) since Neovim requiresend_row > start_rowforhl_eol. Addclear_ns_by_starthelper that deletes extmarks by start position only, preventing adjacent hunk clearing from killing multiline bg extmarks whoseend_rowbleeds into the cleared range. Guardcarry_forward_highlightedwith#entry.hunks == #hunksto force full clear when hunks are added/removed, preventing stale extmarks from repositioned deleted lines.Credit to @phanen for identifying the
hl_eolrequirement (PR #81).