fix: merge profile and startup options
This commit is contained in:
parent
773c3719a1
commit
75cfa52673
1 changed files with 27 additions and 30 deletions
57
src/main.rs
57
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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue