Skip to content

Commit 1f8b38c

Browse files
stevenpollackclaude
andcommitted
feat(worktrees): accept y/n in the remove confirmation
The worktree-removal confirmation now spells out its keys in the copy ("y = delete n / Esc = cancel") and accepts `y` to confirm and `n` to cancel, in addition to the existing Enter/Esc. The y/n handling is gated to the DeleteWorktree action, so every other confirmation dialog (reset, stash, delete branch/tag/remote, aborts) is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BMQxBdr5f3B3jmDtdvGtTu
1 parent d680425 commit 1f8b38c

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/popups/confirm.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
strings, ui,
1010
};
1111
use anyhow::Result;
12-
use crossterm::event::Event;
12+
use crossterm::event::{Event, KeyCode};
1313
use ratatui::{layout::Rect, text::Text, widgets::Clear, Frame};
1414
use std::borrow::Cow;
1515
use ui::style::SharedTheme;
@@ -74,6 +74,14 @@ impl Component for ConfirmPopup {
7474
self.hide();
7575
} else if key_match(e, self.key_config.keys.enter) {
7676
self.confirm();
77+
} else if self.is_worktree_removal() {
78+
// worktree removal additionally accepts explicit
79+
// y/n, as spelled out in its message copy.
80+
match e.code {
81+
KeyCode::Char('y') => self.confirm(),
82+
KeyCode::Char('n') => self.hide(),
83+
_ => {}
84+
}
7785
}
7886

7987
return Ok(EventState::Consumed);
@@ -125,6 +133,10 @@ impl ConfirmPopup {
125133
self.hide();
126134
}
127135

136+
const fn is_worktree_removal(&self) -> bool {
137+
matches!(self.target, Some(Action::DeleteWorktree(_)))
138+
}
139+
128140
fn get_text(&self) -> (String, String) {
129141
if let Some(ref a) = self.target {
130142
return match a {

src/strings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub fn confirm_msg_delete_worktree(
259259
name: &str,
260260
) -> String {
261261
format!(
262-
"Really remove worktree `{name}`? Its working directory will be deleted."
262+
"Really remove worktree `{name}`? Its working directory will be deleted.\n\ny = delete n / Esc = cancel"
263263
)
264264
}
265265
pub fn confirm_title_delete_remote_branch(

0 commit comments

Comments
 (0)