Skip to content

Fix discard unstaged changes incorrectly requiring staged changes#5406

Open
dhanush0x96c wants to merge 1 commit intojesseduffield:masterfrom
dhanush0x96c:fix/discard-menu-logic
Open

Fix discard unstaged changes incorrectly requiring staged changes#5406
dhanush0x96c wants to merge 1 commit intojesseduffield:masterfrom
dhanush0x96c:fix/discard-menu-logic

Conversation

@dhanush0x96c
Copy link

Summary

Fixes #5388

This PR fixes the logic controlling when the "Discard unstaged changes" menu option is disabled in the files panel.

Previously, the option could be incorrectly disabled even when there were unstaged changes available to discard. This change ensures the option is only disabled when there are no unstaged changes.


Problem

The previous condition disabled the menu item when either:

  • The selected files had no staged changes, OR
  • The selected files had no unstaged changes

This was overly restrictive. The availability of the action should depend solely on whether there are unstaged changes. As a result, users were prevented from discarding unstaged changes simply because no staged changes were present.


Solution

The condition has been simplified:

  • The menu item is now disabled only when there are no unstaged changes
  • The presence or absence of staged changes is no longer considered

This aligns the UI behavior with user expectations and the intent of the action.


Visual Changes

Before

  • Unstaged changes present, but action incorrectly disabled
before

After

  • Unstaged changes present, action correctly enabled
after-1
  • No unstaged changes, action correctly disabled
after-2

Testing

  1. Stage some (but not all) changes in a file
  2. Open the discard changes menu for that file
  3. Confirm "Discard unstaged changes" is enabled
  4. Stage all changes in a file
  5. Confirm "Discard unstaged changes" is disabled with the updated message
  6. Modify a file without staging any changes
  7. Confirm "Discard unstaged changes" is enabled

Checklist

  • Cheatsheets are up-to-date (go generate ./...)
  • Code has been formatted
  • [] Tests have been added/updated
  • Text is internationalised
  • [] UserConfig changes (if any) support hot-reloading
  • [] Documentation has been updated (if required)
  • Reviewed changes for errors and inconsistencies

The "Discard unstaged changes" menu item was incorrectly disabled when
no staged changes were present, even if unstaged changes existed. This
change ensures it is only disabled when there are no unstaged changes.
@dhanush0x96c
Copy link
Author

Note: updated the English translation only; other languages are handled via Crowdin.

Copy link

@themavik themavik left a comment

Choose a reason for hiding this comment

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

Disabled state now matches the action: unstaged discard only needs unstaged worktree deltas, not staged ones. Tooltip string lines up with the new check.

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.

Illogical message when deleting unstaged changes

2 participants