diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-02 22:08:13 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-02 22:08:13 +0300 |
| commit | 974a48172d5ad8744d6b54de4538391e80346ab6 (patch) | |
| tree | 4d54e256efa229256e7273577ea34ca7a88058f2 /src | |
| parent | d1471e64834d0c7daf072f11c01c30db35324850 (diff) | |
fix: leave context menu after closing tab
refs #945
Diffstat (limited to 'src')
| -rw-r--r-- | src/app/input/modal.rs | 1 | ||||
| -rw-r--r-- | src/app/input/mouse.rs | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/app/input/modal.rs b/src/app/input/modal.rs index daa84850..31e0aa1e 100644 --- a/src/app/input/modal.rs +++ b/src/app/input/modal.rs @@ -1174,6 +1174,7 @@ impl App { self.focus_workspace_idx_via_api(ws_idx); self.focus_tab_idx_via_api(tab_idx); self.close_active_tab_via_api(); + leave_modal(&mut self.state); } (ContextMenuKind::Pane { pane_id, .. }, Some("Rename pane")) => { open_rename_pane(&mut self.state, pane_id); diff --git a/src/app/input/mouse.rs b/src/app/input/mouse.rs index 7f9f9cde..a4cbc089 100644 --- a/src/app/input/mouse.rs +++ b/src/app/input/mouse.rs @@ -3200,6 +3200,46 @@ mod tests { } #[test] + fn clicking_tab_context_menu_close_leaves_context_menu_mode() { + let mut app = app_for_mouse_test(); + let mut ws = Workspace::test_new("one"); + ws.test_add_tab(Some("two")); + app.state.workspaces = vec![ws]; + app.state.active = Some(0); + app.state.selected = 0; + app.state.mode = Mode::Terminal; + + crate::ui::compute_view(&mut app.state, Rect::new(0, 0, 106, 20)); + let second_tab = app.state.view.tab_hit_areas[1]; + + app.handle_mouse(mouse( + MouseEventKind::Down(MouseButton::Right), + second_tab.x + 1, + second_tab.y, + )); + + let menu = app + .state + .context_menu_rect() + .expect("tab context menu rect"); + app.handle_mouse(mouse( + MouseEventKind::Down(MouseButton::Left), + menu.x + 2, + menu.y + 3, + )); + + assert_eq!(app.state.workspaces[0].tabs.len(), 1); + assert_eq!(app.state.workspaces[0].display_name(), "one"); + assert!(app.state.context_menu.is_none()); + assert_eq!(app.state.mode, Mode::Terminal); + assert!(app + .event_hub + .events_after(0) + .iter() + .any(|(_, event)| { matches!(event.event, crate::api::schema::EventKind::TabClosed) })); + } + + #[test] fn wheel_over_overflowing_tab_bar_switches_tabs() { let mut app = app_for_mouse_test(); let mut ws = Workspace::test_new("one"); |
