Omnibar Enter navigates the current tab instead of spawning a new one
`submit_command` matched every browser's "Enter to navigate" intent to `open_tab(url)`, which always inserts a new `BrowserTab`. So typing `google.com` and hitting Enter on a new-tab page would leave both the new-tab and a fresh google.com tab in the sidebar. Mirror the same in-place navigation rule the shell-level code now uses: `navigate_active_tab(url)` for the Navigate and Search intents, with `open_tab` as the fallback when there's no active tab yet. Tab count only goes up when the user explicitly hits + New Tab. cargo test --workspace: 440 passed, 0 failed.
This commit is contained in:
@@ -29,12 +29,20 @@ impl BrowserCore {
|
||||
let intent = CommandIntent::parse(query)?;
|
||||
match &intent {
|
||||
CommandIntent::Navigate(url) => {
|
||||
// Submitting a URL navigates the current tab in place,
|
||||
// matching every real browser. If there's no active tab
|
||||
// to navigate (no shell yet, no tabs at all), fall
|
||||
// back to spawning a new one.
|
||||
if self.navigate_active_tab(url.clone()).is_err() {
|
||||
self.open_tab(url.clone());
|
||||
}
|
||||
self.command_query.clear();
|
||||
}
|
||||
CommandIntent::Search(query) => {
|
||||
let url = search_url(query, self.search_engine)?;
|
||||
if self.navigate_active_tab(url.clone()).is_err() {
|
||||
self.open_tab(url);
|
||||
}
|
||||
self.command_query.clear();
|
||||
}
|
||||
CommandIntent::Command(command) if self.submit_named_command(command)? => {
|
||||
|
||||
Reference in New Issue
Block a user