Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/terminal_view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ gpui.workspace = true
itertools.workspace = true
language.workspace = true
log.workspace = true
menu.workspace = true
pretty_assertions.workspace = true
project.workspace = true
regex.workspace = true
Expand Down
37 changes: 37 additions & 0 deletions crates/terminal_view/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ impl Domain for TerminalDb {
ALTER TABLE terminals ADD COLUMN working_directory_path TEXT;
UPDATE terminals SET working_directory_path = CAST(working_directory AS TEXT);
),
sql! (
ALTER TABLE terminals ADD COLUMN custom_title TEXT;
),
];
}

Expand Down Expand Up @@ -484,4 +487,38 @@ impl TerminalDb {
WHERE item_id = ? AND workspace_id = ?
}
}

pub async fn save_custom_title(
&self,
item_id: ItemId,
workspace_id: WorkspaceId,
custom_title: Option<String>,
) -> Result<()> {
log::debug!(
"Saving custom title {:?} for item {} in workspace {:?}",
custom_title,
item_id,
workspace_id
);
self.write(move |conn| {
let query = "INSERT INTO terminals (item_id, workspace_id, custom_title)
VALUES (?1, ?2, ?3)
ON CONFLICT (workspace_id, item_id) DO UPDATE SET
custom_title = excluded.custom_title";
let mut statement = Statement::prepare(conn, query)?;
let mut next_index = statement.bind(&item_id, 1)?;
next_index = statement.bind(&workspace_id, next_index)?;
statement.bind(&custom_title, next_index)?;
statement.exec()
})
.await
}

query! {
pub fn get_custom_title(item_id: ItemId, workspace_id: WorkspaceId) -> Result<Option<String>> {
SELECT custom_title
FROM terminals
WHERE item_id = ? AND workspace_id = ?
}
}
}
11 changes: 9 additions & 2 deletions crates/terminal_view/src/terminal_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ impl TerminalPanel {
.active_item()
.and_then(|item| item.downcast::<TerminalView>())
.map(|terminal_view| terminal_view.read(cx).focus_handle.clone());
if !pane.has_focus(window, cx) && !pane.context_menu_focused(window, cx) {
let has_focused_rename_editor = pane
.active_item()
.and_then(|item| item.downcast::<TerminalView>())
.is_some_and(|view| view.read(cx).rename_editor_is_focused(window, cx));
if !pane.has_focus(window, cx)
&& !pane.context_menu_focused(window, cx)
&& !has_focused_rename_editor
{
return (None, None);
}
let focus_handle = pane.focus_handle(cx);
Expand Down Expand Up @@ -1944,7 +1951,7 @@ mod tests {
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings(cx, |settings| {
settings.terminal.get_or_insert_default().project.shell =
Some(settings::Shell::Program("asdf".to_owned()));
Some(settings::Shell::Program("__nonexistent_shell__".to_owned()));
});
});
});
Expand Down
Loading
Loading