Skip to content

Fix the Edit menu offering Copy SHA with nothing selected - #626

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-copy-menu-validation
Sep 13, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-copy-menu-validation

Conversation

@goneng

@goneng goneng commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Copy items that cannot copy anything should not be offered.

With no commit selected, Edit > Copy SHA, Copy short SHA, Copy Patch and Copy
stay enabled, and choosing one quietly copies nothing. The history controller
answers every action it implements with a blanket YES, and that answer comes
before the check written for the copy items, so the selection check below it
has never run.

The commit context menu is unaffected either way: it sets
autoenablesItems = NO, so nothing there is validated.

  • Ask whether anything is selected before the blanket YES
  • Cover the four copy items with a test that fails on the old order

Test plan

  • make unit-test: 89 tests, 0 failures, 2 of them new (in
    PBGitHistoryMenuValidationTests)
  • Confirmed red first: on the old order,
    testTheCopyItemsAreOffWithNothingSelected fails for all four items
  • Not checked by hand in a running app: with no commit selected, Edit > Copy
    SHA and friends should now be greyed out, and the commit context menu
    should be unchanged

@hannesa2

Copy link
Copy Markdown
Contributor

Please keep in mind, that #406 is already solved and the solution is already merged

Copy items that cannot copy anything should not be offered.

The history controller answers every action it implements with a blanket
YES, and that answer comes before the check written for the copy items,
so Copy, Copy SHA, Copy short SHA and Copy Patch stay enabled with an
empty selection and quietly copy nothing.

* Ask whether anything is selected before the blanket YES
* Cover the four copy items with a test that fails on the old order
@goneng
goneng force-pushed the fix-copy-menu-validation branch from 54f7a57 to 008c5d8 Compare September 13, 2026 08:42
@goneng

goneng commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Please keep in mind, that #406 is already solved and the solution is already merged

Yes, the new issue is "on top" of Issue #406 - PR #621 changes which commits the copy actions read,
and this one changes whether the items are even offered (because the menu offers to copy a commit-SHA even when non is selected).

@goneng
goneng marked this pull request as ready for review September 13, 2026 09:50
@hannesa2
hannesa2 merged commit 3a4a41d into gitx:master Sep 13, 2026
3 checks passed
@goneng
goneng deleted the fix-copy-menu-validation branch September 13, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants