Measure refresh latency independently and retain intended result selection
This commit is contained in:
1 parent
373ed1ed49
commit
8b993b23d7
7 files changed
+188
-11
No files matched your search
@@ -0,0 +1,24 @@
|
||||
/** Preserve the user's result choice while progressive indexing hides it briefly. */
|
||||
export class ResultSelection {
|
||||
private scope: string | null = null;
|
||||
private intendedPath: string | null = null;
|
||||
|
||||
begin(scope: string) {
|
||||
if (scope !== this.scope) {
|
||||
this.scope = scope;
|
||||
this.intendedPath = null;
|
||||
}
|
||||
}
|
||||
|
||||
choose(path: string) {
|
||||
this.intendedPath = path;
|
||||
}
|
||||
|
||||
resolve(paths: readonly string[]): number {
|
||||
if (!paths.length) return -1;
|
||||
if (this.intendedPath === null) this.intendedPath = paths[0];
|
||||
const intended = paths.indexOf(this.intendedPath);
|
||||
// A temporary fallback is presentation, not a new user choice.
|
||||
return intended >= 0 ? intended : 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user