diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-28 04:18:55 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-28 04:51:05 +0300 |
| commit | 37bdff5bbe7f6b50dce2d8920a08bdaafd4fecda (patch) | |
| tree | 99cdbfbd8e2eaef22d5db08c153bf75bc1689a82 /src/app/input/navigate.rs | |
| parent | 67e48c0cc9aa1c18b743e3be54a69a4edab90680 (diff) | |
fix: seed workspace rename from live cwd
Diffstat (limited to 'src/app/input/navigate.rs')
| -rw-r--r-- | src/app/input/navigate.rs | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs index 032ba8ae..e524c304 100644 --- a/src/app/input/navigate.rs +++ b/src/app/input/navigate.rs @@ -684,7 +684,7 @@ pub(super) fn execute_navigate_action_in_context( } NavigateAction::RenameWorkspace => { if let Some(ws_idx) = workspace_action_target(state, context) { - super::modal::open_rename_workspace(state, ws_idx); + super::modal::open_rename_workspace(state, terminal_runtimes, ws_idx); } } NavigateAction::CloseWorkspace => { @@ -963,7 +963,9 @@ mod tests { use super::super::{state_with_workspaces, unique_temp_path, wait_for_file}; use super::*; - use crate::{app::App, config::Config, input::TerminalKey, workspace::Workspace}; + use crate::{ + app::App, config::Config, input::TerminalKey, terminal::TerminalState, workspace::Workspace, + }; fn mark_worktree_space_member(state: &mut AppState, ws_idx: usize, key: &str) { state.workspaces[ws_idx].worktree_space = Some(crate::workspace::WorktreeSpaceMembership { @@ -1002,6 +1004,31 @@ mod tests { } #[test] + fn rename_workspace_prefills_live_terminal_cwd_label() { + let mut state = state_with_workspaces(&["stale"]); + let root = state.workspaces[0].tabs[0].root_pane; + let terminal_id = state.workspaces[0].panes[&root] + .attached_terminal_id + .clone(); + state.workspaces[0].custom_name = None; + state.workspaces[0].identity_cwd = "/__herdr_original__".into(); + state.terminals.insert( + terminal_id.clone(), + TerminalState::new(terminal_id, "/__herdr_projects__".into()), + ); + state.keybinds.rename_workspace = crate::config::ActionKeybinds::prefix("g"); + + handle_navigate_key( + &mut state, + KeyEvent::new(KeyCode::Char('g'), KeyModifiers::empty()), + ); + + assert_eq!(state.mode, Mode::RenameWorkspace); + assert_eq!(state.name_input, "__herdr_projects__"); + assert_eq!(state.workspaces[0].display_name(), "__herdr_original__"); + } + + #[test] fn prefix_rename_workspace_targets_active_workspace_not_stale_selection() { let mut state = state_with_workspaces(&["main", "issue"]); let mut terminal_runtimes = TerminalRuntimeRegistry::new(); |
