Run tab actions from command bar

This commit is contained in:
2026-05-07 19:38:30 -04:00
parent ba312e5b85
commit 1405b7c494
2 changed files with 91 additions and 0 deletions
+22
View File
@@ -181,6 +181,10 @@ impl BrowserCore {
self.open_tab(url);
self.command_query.clear();
}
CommandIntent::Command(command) if self.submit_named_command(command)? => {
self.command_query.clear();
}
CommandIntent::Command(_) => {}
CommandIntent::ScopedSearch { scope: CommandScope::Tabs, query } => {
if let Some(tab_id) = self.find_tab_match(query) {
self.select_tab(&tab_id)?;
@@ -231,6 +235,24 @@ impl BrowserCore {
Ok(next_tab_id)
}
fn submit_named_command(&mut self, command: &str) -> Result<bool, CoreError> {
match command.trim().to_ascii_lowercase().as_str() {
"new-tab" => {
self.open_tab(self.new_tab_url.clone());
Ok(true)
}
"close-tab" => {
self.close_active_tab()?;
Ok(true)
}
"favorite" | "toggle-favorite" => {
self.toggle_active_tab_favorite()?;
Ok(true)
}
_ => Ok(false),
}
}
fn active_tab_index(&self) -> Result<usize, CoreError> {
self.tabs
.iter()