aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRajyavardhan Singh <132651154+imrajyavardhan12@users.noreply.github.com>2026-06-09 21:36:11 +0530
committerGitHub <noreply@github.com>2026-06-09 19:06:11 +0300
commit22fa503d83e0de7b49cd37393644353e4f5f3faa (patch)
tree5e3d1edc1e15505244e4f33f301e1a0dda609304 /src
parent698eb51f543af47ba7a974d0d78f1bf0cca2cd53 (diff)
fix: respect prompt_new_tab_name in mouse click handlers (#521)
Diffstat (limited to 'src')
-rw-r--r--src/app/input/mouse.rs68
1 files changed, 66 insertions, 2 deletions
diff --git a/src/app/input/mouse.rs b/src/app/input/mouse.rs
index a241dadb..2e2a94aa 100644
--- a/src/app/input/mouse.rs
+++ b/src/app/input/mouse.rs
@@ -451,7 +451,12 @@ impl AppState {
return None;
}
if self.on_new_tab_button(mouse.column, mouse.row) {
- open_new_tab_dialog(self);
+ if self.prompt_new_tab_name {
+ open_new_tab_dialog(self);
+ } else {
+ self.request_new_tab = true;
+ self.mode = Mode::Terminal;
+ }
return None;
}
@@ -1047,7 +1052,12 @@ impl AppState {
self.mode = Mode::Terminal;
}
Some(crate::ui::MobileSwitcherTarget::NewTab) => {
- open_new_tab_dialog(self);
+ if self.prompt_new_tab_name {
+ open_new_tab_dialog(self);
+ } else {
+ self.request_new_tab = true;
+ self.mode = Mode::Terminal;
+ }
}
Some(crate::ui::MobileSwitcherTarget::Tab(tab_idx)) => {
self.switch_tab(tab_idx);
@@ -3125,6 +3135,60 @@ mod tests {
}
#[test]
+ fn mobile_switcher_new_tab_skips_dialog_when_prompt_disabled() {
+ let mut app = app_for_mouse_test();
+ let mut ws = Workspace::test_new("one");
+ ws.test_add_tab(Some("logs"));
+ app.state.workspaces = vec![ws];
+ app.state.active = Some(0);
+ app.state.selected = 0;
+ app.state.mode = Mode::Terminal;
+ app.state.prompt_new_tab_name = false;
+
+ crate::ui::compute_view(&mut app.state, Rect::new(0, 0, 44, 20));
+ let switch = app.state.view.mobile_menu_hit_area;
+ app.handle_mouse(mouse(
+ MouseEventKind::Down(MouseButton::Left),
+ switch.x + 1,
+ switch.y + 1,
+ ));
+ let viewport = crate::ui::mobile_switcher_areas(&app.state).viewport;
+
+ app.handle_mouse(mouse(
+ MouseEventKind::Down(MouseButton::Left),
+ viewport.x + 2,
+ viewport.y + 5,
+ ));
+ assert_eq!(app.state.mode, Mode::Terminal);
+ assert!(!app.state.creating_new_tab);
+ assert!(app.state.request_new_tab);
+ assert!(app.state.requested_new_tab_name.is_none());
+ }
+
+ #[test]
+ fn desktop_new_tab_button_skips_dialog_when_prompt_disabled() {
+ let mut app = app_for_mouse_test();
+ app.state.workspaces = vec![Workspace::test_new("one")];
+ app.state.active = Some(0);
+ app.state.selected = 0;
+ app.state.mode = Mode::Terminal;
+ app.state.prompt_new_tab_name = false;
+
+ crate::ui::compute_view(&mut app.state, Rect::new(0, 0, 120, 40));
+ let new_tab_area = app.state.view.new_tab_hit_area;
+ app.handle_mouse(mouse(
+ MouseEventKind::Down(MouseButton::Left),
+ new_tab_area.x + 1,
+ new_tab_area.y,
+ ));
+
+ assert_eq!(app.state.mode, Mode::Terminal);
+ assert!(!app.state.creating_new_tab);
+ assert!(app.state.request_new_tab);
+ assert!(app.state.requested_new_tab_name.is_none());
+ }
+
+ #[test]
fn mobile_switcher_swallows_non_left_mouse_events() {
let mut app = app_for_mouse_test();
app.state.workspaces = vec![Workspace::test_new("one")];