Files
orca/src/shared/quick-open-query-target.ts
T
Neil fff8718c76 Improve Quick Open matching, file locations and recent history (#25371)
* Match Quick Open queries across path terms and identifier separators

* Honor ignored-file and symlink preferences on file inventory hosts

* Open pasted file locations and remember successful workspace file visits

* Verify bounded directory listing preferences across execution routes

* Preserve symlink preferences on legacy directory fallback

* Preserve bounded Quick Open terms and separator alternatives

* Revoke stale Quick Open selections and preserve literal file locations

* Validate recent Quick Open candidates independently on their host

* Use complete old-host inventory fixtures for Quick Open compatibility

* Keep Quick Open validation current across palette and workspace changes

* Route recent candidates through relay file listing dispatch

* Record Quick Open hook renders as test snapshots

* Localize Quick Open eligibility errors and search aliases

* Validate file inventory with bundled search and runtime preferences

* test: use directory junction fixtures on Windows

* fix: negotiate Quick Open policies with nested SSH hosts

* fix: refresh cached linked folders after target changes

* Retry stale expanded links after reads settle and targets recover

* Scope stale refresh request lifetime to the visible workspace

* test: seed linked-folder fixture before watcher startup

* Keep Quick Open responsive and compatible with older hosts

* Exercise directory discovery with unprivileged Windows junctions
2026-10-05 21:52:28 -07:00

34 lines
1.2 KiB
TypeScript

import { isWindowsAbsolutePathLike } from './cross-platform-path'
import { isQuickOpenQueryTooLarge } from './quick-open-path-search'
export type QuickOpenQueryTarget = { pathQuery: string; line?: number; column?: number }
export function parseQuickOpenQueryTarget(query: string): QuickOpenQueryTarget {
if (isQuickOpenQueryTooLarge(query)) {
return { pathQuery: query }
}
const trimmed = query.trim()
const match = /^(.*?):([0-9]+)(?::([0-9]+))?$/.exec(trimmed)
if (!match || !match[1] || /^[A-Za-z]$/.test(match[1]) || match[1].endsWith(':')) {
return { pathQuery: trimmed }
}
const line = Number(match[2])
const column = match[3] === undefined ? undefined : Number(match[3])
if (
!Number.isSafeInteger(line) ||
line < 1 ||
(column !== undefined && (!Number.isSafeInteger(column) || column < 1))
) {
return { pathQuery: trimmed }
}
return { pathQuery: match[1], line, ...(column === undefined ? {} : { column }) }
}
export function isQuickOpenAbsolutePath(query: string): boolean {
return (
!isQuickOpenQueryTooLarge(query) &&
!query.includes('\0') &&
(query.startsWith('/') || isWindowsAbsolutePathLike(query))
)
}