Use terminal titles for buttons

This commit is contained in:
Joseph Lyons 2023-03-07 15:04:12 -05:00
parent c80942ea00
commit 0a3f0c5252
3 changed files with 39 additions and 36 deletions

View file

@ -30,7 +30,7 @@ use terminal::{
},
Event, Terminal,
};
use util::{truncate_and_trailoff, ResultExt};
use util::ResultExt;
use workspace::{
item::{Item, ItemEvent},
notifications::NotifyResultExt,
@ -547,38 +547,7 @@ impl Item for TerminalView {
tab_theme: &theme::Tab,
cx: &gpui::AppContext,
) -> ElementBox {
let title = self
.terminal()
.read(cx)
.foreground_process_info
.as_ref()
.map(|fpi| {
format!(
"{} — {}",
truncate_and_trailoff(
&fpi.cwd
.file_name()
.map(|name| name.to_string_lossy().to_string())
.unwrap_or_default(),
25
),
truncate_and_trailoff(
&{
format!(
"{}{}",
fpi.name,
if fpi.argv.len() >= 1 {
format!(" {}", (&fpi.argv[1..]).join(" "))
} else {
"".to_string()
}
)
},
25
)
)
})
.unwrap_or_else(|| "Terminal".to_string());
let title = self.terminal().read(cx).title();
Flex::row()
.with_child(