Skip to content

fix(inline): render extmarks before the buffer becomes visible#174

Merged
dlyongemallo merged 1 commit into
mainfrom
diff1_inline_initial_display
May 18, 2026
Merged

fix(inline): render extmarks before the buffer becomes visible#174
dlyongemallo merged 1 commit into
mainfrom
diff1_inline_initial_display

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

@dlyongemallo dlyongemallo commented May 17, 2026

Fixes #172.

Copilot AI review requested due to automatic review settings May 17, 2026 16:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rework create/use_entry/create_post to render extmarks before open_files displays the buffer, while scoping the inline namespace to prevent window leakage.
  • Add opts.winid support to inline_diff.render() so full_width padding can be computed against an “eventual” target window.
  • Add functional regression tests covering prerender behavior, namespace scoping, and hinted full_width padding.

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() and async.scheduler(), the validity check doesn’t confirm that the captured bufnr still matches the current self.b.file.bufnr. If self.b.file changes during the await, the render can target the wrong buffer. Recompute/compare bufnr after 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.

Comment thread lua/diffview/scene/layouts/diff_1_inline.lua Outdated
@dlyongemallo dlyongemallo force-pushed the diff1_inline_initial_display branch 2 times, most recently from af1102f to 804e5cd Compare May 17, 2026 19:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread lua/diffview/scene/layouts/diff_1_inline.lua
@dlyongemallo dlyongemallo merged commit dac6683 into main May 18, 2026
14 checks passed
@dlyongemallo dlyongemallo deleted the diff1_inline_initial_display branch May 18, 2026 14:08
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.

[Bug] diff1_inline flashes blank buffer with green line and then current buffer before showing actual changes

2 participants