Skip to content

fix(file): load existing unloaded buffer in _create_local_buffer#203

Merged
dlyongemallo merged 1 commit into
mainfrom
tab_race_condition
May 23, 2026
Merged

fix(file): load existing unloaded buffer in _create_local_buffer#203
dlyongemallo merged 1 commit into
mainfrom
tab_race_condition

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

Makes rapidly switching files (by pressing <tab>/<s-tab>) much more stable.

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 improves stability when rapidly switching between files by ensuring Diffview doesn’t reuse an existing unloaded file buffer (created by other plugins via bufadd()-style behavior) without first loading its contents from disk.

Changes:

  • In vcs.File:_create_local_buffer(), force-load an existing matching buffer via bufload() when it is currently unloaded.
  • Add a functional regression test covering the “pre-existing unloaded buffer” scenario for RevType.LOCAL.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lua/diffview/vcs/file.lua Ensures reused LOCAL buffers are loaded from disk before diff rendering, preventing empty-placeholder reuse.
lua/diffview/tests/functional/file_spec.lua Adds a regression test that reproduces an unloaded named buffer and verifies Diffview loads its content.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dlyongemallo dlyongemallo merged commit cf217dd into main May 23, 2026
11 checks passed
@dlyongemallo dlyongemallo deleted the tab_race_condition branch May 23, 2026 05:13
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