fix(search): compare the echoed q in trimmed form in the echo guard

Adoption trims, so a same-page imperative navigation still carrying a
not-yet-rewritten untrimmed q adopts to exactly the applied state —
syncing it could only cancel a pending debounce. Comparing the trimmed
form closes that window.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Fable 5 committed 2026-08-23 09:19:33 +02:00
1 parent 935200c4b8
commit c2143c7eb5
1 file changed
+5 -1
@@ -162,10 +162,14 @@ export class WorkspaceShellSearchSyncService {
// so back/forward re-applies what the entry carries even mid-typing.
// `lastSuccessfulNavigation` is set immediately before `NavigationEnd`
// is emitted, so it describes the navigation being handled here.
//
// The comparison trims `nextTerm` because adoption would too: a URL
// still carrying a not-yet-rewritten untrimmed `q` adopts to exactly
// the applied state, so syncing could only cancel a pending debounce.
if (
previousUrl !== null &&
getRoutePath(url) === getRoutePath(previousUrl) &&
nextTerm === this.appliedSearchQuery() &&
nextTerm.trim() === this.appliedSearchQuery() &&
this.router.lastSuccessfulNavigation()?.trigger === 'imperative'
) {
return;