Skip to content

perf(ui): use ranged extmarks for line highlights - #461

Merged
esmuellert merged 2 commits into
esmuellert:mainfrom
richardgill:perf-ranged-line-extmarks
Jul 22, 2026
Merged

perf(ui): use ranged extmarks for line highlights#461
esmuellert merged 2 commits into
esmuellert:mainfrom
richardgill:perf-ranged-line-extmarks

Conversation

@richardgill

Copy link
Copy Markdown
Collaborator

Summary

Replace per-line highlight extmarks with one ranged extmark for each contiguous changed range.

This reduces Neovim API calls and extmark objects while preserving highlight groups, hl_eol, priority, character-level highlights, and filler behavior.

Performance

Validated against the existing prototype benchmark:

  • Full rewrite median rerender: 3.258 ms → 1.888 ms (42.1% faster)
  • Large insertion extmarks: 1,001 → 2
  • Full rewrite extmarks: 4,000 → 2,002
  • Lower extmark counts reduce Neovim’s internal memory usage for large contiguous changes, although exact memory savings were not measured

Sparse and isolated single-line changes are effectively unchanged.

@richardgill
richardgill marked this pull request as ready for review July 20, 2026 14:55
@richardgill

Copy link
Copy Markdown
Collaborator Author

@esmuellert PR build failed. I think this is the fix #462

esmuellert added a commit that referenced this pull request Jul 22, 2026
- Fixes the [Windows CI failure in
#461](https://github.com/esmuellert/codediff.nvim/actions/runs/29659694570/job/88489171079):
CodeDiff tries to load `/libvscode_diff_nil.dll`.
- Current Neovim nightly can mishandle repeated `:h` modifiers on
relative `./lua/...` paths after
[neovim#40447](neovim/neovim#40447), resolving
the plugin root to `/` and leaving `VERSION` nil. See
[neovim#40545](neovim/neovim#40545).
- Make the module source absolute with `:p` before traversing parents,
and reuse that root for VERSION loading.
- Verified on [Windows x64 and ARM64
CI](https://github.com/richardgill/codediff.nvim/actions/runs/29828651463).
@esmuellert
esmuellert merged commit 1aab69b into esmuellert:main Jul 22, 2026
13 checks passed
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.

2 participants