From 765180baaa392bacc845d5c9613cbcf1bcae7c0f Mon Sep 17 00:00:00 2001 From: sirily11 <32106111+sirily11@users.noreply.github.com> Date: Wed, 3 Jun 2026 01:00:05 +0800 Subject: [PATCH] fix: disable Cmd+A select-all shortcut when no section is focused Let the keystroke fall through to the focused field's native select-all (e.g. the commit-message editor) instead of grabbing the unstaged list. Co-Authored-By: Claude Opus 4.8 (1M context) --- RxCode/Views/Inspector/ChangesView.swift | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/RxCode/Views/Inspector/ChangesView.swift b/RxCode/Views/Inspector/ChangesView.swift index e0b96942..d07ee5cb 100644 --- a/RxCode/Views/Inspector/ChangesView.swift +++ b/RxCode/Views/Inspector/ChangesView.swift @@ -108,13 +108,17 @@ struct ChangesView: View { } /// Cmd+A hooks up to whichever section is currently focused. Hidden button - /// avoids stealing focus from the visible UI. + /// avoids stealing focus from the visible UI. Disabled when no section is + /// focused (e.g. the commit-message editor or another field has focus) so + /// the keystroke falls through to the focused field's native select-all + /// instead of grabbing the unstaged list. @ViewBuilder private var selectAllShortcut: some View { Button("Select All in Section") { selectAllInFocusedSection() } .keyboardShortcut("a", modifiers: .command) + .disabled(focusedSection == nil) .frame(width: 0, height: 0) .opacity(0) .accessibilityHidden(true) @@ -132,15 +136,9 @@ struct ChangesView: View { case .staged: selectedStaged = Set(staged.map { $0.displayPath }) case .none: - // No section focused — default to whichever has files, preferring - // unstaged. Keeps Cmd+A useful right after the view appears. - if !unstaged.isEmpty { - selectedUnstaged = Set(unstaged.map { $0.displayPath }) - focusedSection = .unstaged - } else if !staged.isEmpty { - selectedStaged = Set(staged.map { $0.displayPath }) - focusedSection = .staged - } + // No section focused — the shortcut is disabled in this state, so + // the keystroke is handled by whatever field has focus instead. + break } }