From 75cfa526730dddb361161e724fdc8e2db67208e3 Mon Sep 17 00:00:00 2001 From: Adil Hanney Date: Mon, 16 Feb 2026 23:32:19 +0000 Subject: [PATCH] fix: merge profile and startup options --- src/main.rs | 57 +++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/main.rs b/src/main.rs index db3aecf..6ed5806 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,10 +37,11 @@ use std::{ collections::{BTreeMap, BTreeSet, HashMap}, env, error::Error, - fs, process, + fs, + path::PathBuf, + process, rc::Rc, sync::{LazyLock, Mutex, atomic::Ordering}, - path::PathBuf, }; use tokio::sync::mpsc; @@ -1522,40 +1523,36 @@ impl App { Some(colors) => { let current_pane = self.pane_model.focused(); if let Some(tab_model) = self.pane_model.active_mut() { - // Use the startup options, profile options, or defaults - let (options, tab_title_override) = match self.startup_options.take() { - Some(options) => (options, None), - None => match profile_id_opt - .and_then(|profile_id| self.config.profiles.get(&profile_id)) - { - Some(profile) => { - let mut shell = None; + let mut options = self.startup_options.take().unwrap_or_default(); + let mut tab_title_override = None; + if let Some(profile) = profile_id_opt + .and_then(|profile_id| self.config.profiles.get(&profile_id)) + { + // Merge profile and startup options, preferring startup options + options = tty::Options { + shell: options.shell.or_else(|| { if let Some(mut args) = shlex::split(&profile.command) { if !args.is_empty() { let command = args.remove(0); - shell = Some(tty::Shell::new(command, args)); + return Some(tty::Shell::new(command, args)); } } - let working_directory = - (!profile.working_directory.is_empty()) - .then(|| profile.working_directory.clone().into()); + return None; + }), + working_directory: options.working_directory.or_else(|| { + (!profile.working_directory.is_empty()) + .then(|| profile.working_directory.clone().into()) + }), + drain_on_exit: options.drain_on_exit || profile.drain_on_exit, + ..options + }; + tab_title_override = if profile.tab_title.is_empty() { + None + } else { + Some(profile.tab_title.clone()) + }; + } - let options = tty::Options { - shell, - working_directory, - drain_on_exit: profile.drain_on_exit, - env: HashMap::new(), - }; - let tab_title_override = if profile.tab_title.is_empty() { - None - } else { - Some(profile.tab_title.clone()) - }; - (options, tab_title_override) - } - None => (Options::default(), None), - }, - }; let entity = tab_model .insert() .text(