Skip to content

feat: add option to control behavior when rejecting new file diffs #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: thomask33/feat_redesign_diff_view_with_horizontal_layout_and_new_tab_options
Choose a base branch
from

Conversation

ThomasK33
Copy link
Member

Add option to control behavior when rejecting new file diffs

This PR adds a new configuration option on_new_file_reject that controls what happens when a user rejects a diff for a new file:

  • keep_empty (default): Leaves the empty buffer in place
  • close_window: Closes the placeholder split window

Previously, when rejecting a new file diff, the plugin would always try to delete the original buffer. This could cause issues when the buffer was reused from an existing empty buffer, leading to potential crashes when attempting to reopen a diff.

The PR includes:

  • New configuration option in config.lua with validation
  • Type definition in types.lua
  • Logic in diff.lua to track whether the original buffer was created by the plugin
  • Only delete the original buffer on reject if it was created by the plugin
  • Unit test to verify the fix works correctly

This change improves stability when working with new files and gives users more control over the UI behavior.

@ThomasK33 ThomasK33 marked this pull request as ready for review August 8, 2025 10:46
Copy link
Member Author

ThomasK33 commented Aug 8, 2025

Change-Id: Idc973b23ff2a00ce2e9142e8c2b941b114ef7059
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33 ThomasK33 force-pushed the thomask33/feat_redesign_diff_view_with_horizontal_layout_and_new_tab_options branch from 7ab50da to f8c7db8 Compare August 8, 2025 19:34
@ThomasK33 ThomasK33 force-pushed the thomask33/feat_add_on_new_file_reject_option_to_control_empty_buffer_behavior branch from b350b53 to 0bcb677 Compare August 8, 2025 19:34
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] crashes with new files
1 participant