fix(inline): render extmarks before the buffer becomes visible#174
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses an inline diff regression where the “b” buffer could become visible before inline-diff extmarks were rendered, causing a first redraw without highlights. It introduces a prerender step to lay down extmarks before open_files swaps the window buffer, and extends full_width deletion padding computation to accept a window hint when the buffer isn’t displayed yet.
Changes:
- Add
Diff1Inline:_prerender()and reworkcreate/use_entry/create_postto render extmarks beforeopen_filesdisplays the buffer, while scoping the inline namespace to prevent window leakage. - Add
opts.winidsupport toinline_diff.render()sofull_widthpadding can be computed against an “eventual” target window. - Add functional regression tests covering prerender behavior, namespace scoping, and hinted
full_widthpadding.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lua/diffview/scene/layouts/diff_1_inline.lua |
Adds _prerender, refactors render flow to avoid first-draw highlight gaps, and adds a create_post override for scoping + full_width follow-up repaint. |
lua/diffview/scene/inline_diff.lua |
Enhances full_width padding target calculation to consider an optional winid hint. |
lua/diffview/tests/functional/layouts_spec.lua |
Adds regression tests for prerendering, nulled/binary behavior, scoping, and create_post repaint gating. |
lua/diffview/tests/functional/inline_diff_spec.lua |
Adds tests asserting full_width padding behavior when the buffer is undisplayed but opts.winid is provided. |
Comments suppressed due to low confidence (1)
lua/diffview/scene/layouts/diff_1_inline.lua:475
- Similarly in
_render_inline, after awaiting_load_old_lines()andasync.scheduler(), the validity check doesn’t confirm that the capturedbufnrstill matches the currentself.b.file.bufnr. Ifself.b.filechanges during the await, the render can target the wrong buffer. Recompute/comparebufnrafter the yield before continuing.
local old_lines = self._cached_old_lines
if old_lines == nil then
old_lines = await(self:_load_old_lines())
await(async.scheduler())
if
not (
self.b
and self.b:is_valid()
and self.b.file
and self.b.file:is_valid()
and api.nvim_buf_is_valid(bufnr)
)
then
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
af1102f to
804e5cd
Compare
804e5cd to
d0df241
Compare
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.
Fixes #172.