fix: merge profile and startup options
This commit is contained in:
parent
773c3719a1
commit
75cfa52673
1 changed files with 27 additions and 30 deletions
41
src/main.rs
41
src/main.rs
|
|
@ -37,10 +37,11 @@ use std::{
|
||||||
collections::{BTreeMap, BTreeSet, HashMap},
|
collections::{BTreeMap, BTreeSet, HashMap},
|
||||||
env,
|
env,
|
||||||
error::Error,
|
error::Error,
|
||||||
fs, process,
|
fs,
|
||||||
|
path::PathBuf,
|
||||||
|
process,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
sync::{LazyLock, Mutex, atomic::Ordering},
|
sync::{LazyLock, Mutex, atomic::Ordering},
|
||||||
path::PathBuf,
|
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
|
@ -1522,40 +1523,36 @@ impl App {
|
||||||
Some(colors) => {
|
Some(colors) => {
|
||||||
let current_pane = self.pane_model.focused();
|
let current_pane = self.pane_model.focused();
|
||||||
if let Some(tab_model) = self.pane_model.active_mut() {
|
if let Some(tab_model) = self.pane_model.active_mut() {
|
||||||
// Use the startup options, profile options, or defaults
|
let mut options = self.startup_options.take().unwrap_or_default();
|
||||||
let (options, tab_title_override) = match self.startup_options.take() {
|
let mut tab_title_override = None;
|
||||||
Some(options) => (options, None),
|
if let Some(profile) = profile_id_opt
|
||||||
None => match profile_id_opt
|
|
||||||
.and_then(|profile_id| self.config.profiles.get(&profile_id))
|
.and_then(|profile_id| self.config.profiles.get(&profile_id))
|
||||||
{
|
{
|
||||||
Some(profile) => {
|
// Merge profile and startup options, preferring startup options
|
||||||
let mut shell = None;
|
options = tty::Options {
|
||||||
|
shell: options.shell.or_else(|| {
|
||||||
if let Some(mut args) = shlex::split(&profile.command) {
|
if let Some(mut args) = shlex::split(&profile.command) {
|
||||||
if !args.is_empty() {
|
if !args.is_empty() {
|
||||||
let command = args.remove(0);
|
let command = args.remove(0);
|
||||||
shell = Some(tty::Shell::new(command, args));
|
return Some(tty::Shell::new(command, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let working_directory =
|
return None;
|
||||||
|
}),
|
||||||
|
working_directory: options.working_directory.or_else(|| {
|
||||||
(!profile.working_directory.is_empty())
|
(!profile.working_directory.is_empty())
|
||||||
.then(|| profile.working_directory.clone().into());
|
.then(|| profile.working_directory.clone().into())
|
||||||
|
}),
|
||||||
let options = tty::Options {
|
drain_on_exit: options.drain_on_exit || profile.drain_on_exit,
|
||||||
shell,
|
..options
|
||||||
working_directory,
|
|
||||||
drain_on_exit: profile.drain_on_exit,
|
|
||||||
env: HashMap::new(),
|
|
||||||
};
|
};
|
||||||
let tab_title_override = if profile.tab_title.is_empty() {
|
tab_title_override = if profile.tab_title.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(profile.tab_title.clone())
|
Some(profile.tab_title.clone())
|
||||||
};
|
};
|
||||||
(options, tab_title_override)
|
|
||||||
}
|
}
|
||||||
None => (Options::default(), None),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let entity = tab_model
|
let entity = tab_model
|
||||||
.insert()
|
.insert()
|
||||||
.text(
|
.text(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue