From 5d290517eeee63eae63a50bb1858e392d896fbba Mon Sep 17 00:00:00 2001 From: lwad Date: Tue, 6 Feb 2024 16:05:41 +0000 Subject: [PATCH] fix: Allow for non-existence of base session --- src/session.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/session.rs b/src/session.rs index 1662b74..2f683ab 100644 --- a/src/session.rs +++ b/src/session.rs @@ -85,15 +85,18 @@ pub fn focus_project(projects: &BTreeMap, project_name: Option Tmux::with_command( - NewSession::new() - .session_name(&session_name) - .start_directory(&projects[&session_name]) - .detached(), - ) - .status() - .unwrap() - .success(), + false => { + let base_directory = "~".to_string(); + Tmux::with_command( + NewSession::new() + .session_name(&session_name) + .start_directory(projects.get(&session_name).unwrap_or(&base_directory)) + .detached(), + ) + .status() + .unwrap() + .success() + } true => true, };