Skip to content

fix(scene): cancel buffer creation for deactivated files#40

Merged
dlyongemallo merged 1 commit intomainfrom
fix_too_fast_buffer_creation
Mar 12, 2026
Merged

fix(scene): cancel buffer creation for deactivated files#40
dlyongemallo merged 1 commit intomainfrom
fix_too_fast_buffer_creation

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings March 12, 2026 13:39
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 fixes a performance/UX issue where buffer creation for diff files would continue even after the user navigated away, by checking the active flag at two points in create_buffer and short-circuiting early. The cancelled error is suppressed in the window's load_file to avoid confusing error messages.

Changes:

  • Add early-exit checks in File.create_buffer before and after produce_data(), cleaning up allocated buffers and raising a sentinel CANCELLED error
  • Change File.active default from false to true (previously never explicitly set to true), and add an early bail-out in Window.load_file for inactive files
  • Add functional tests covering both cancellation scenarios

Reviewed changes

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

File Description
lua/diffview/vcs/file.lua Add CANCELLED sentinel, default active to true, add two cancellation checks in create_buffer
lua/diffview/scene/window.lua Skip load_file for inactive files, suppress CANCELLED errors
lua/diffview/tests/functional/file_spec.lua Tests for both pre- and mid-produce_data cancellation
lua/diffview/tests/functional/window_spec.lua Tests for window-level bail-out and mid-async cancellation

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

@dlyongemallo dlyongemallo force-pushed the fix_too_fast_buffer_creation branch from 0520575 to c20ffc9 Compare March 12, 2026 14:06
@dlyongemallo dlyongemallo merged commit ffd9aaf into main Mar 12, 2026
2 checks passed
@dlyongemallo dlyongemallo deleted the fix_too_fast_buffer_creation branch March 12, 2026 14:10
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