fix(app): incremental scrollback search
Search only ran on Enter; typing merely reset the counter to 0/0, so a visible term showed no matches until the user pressed Enter. run() now takes an optional query override and onChange fires it on every keystroke for search-as-you-type, while Enter/Shift+Enter still navigate matches. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+11
-5
@@ -45,16 +45,17 @@ export function SearchBar({
|
||||
};
|
||||
}, [surfaceId]);
|
||||
|
||||
function run(forward: boolean) {
|
||||
function run(forward: boolean, override?: string) {
|
||||
if (!surfaceId) return;
|
||||
const addon = getSearch(surfaceId);
|
||||
if (!addon || !term) {
|
||||
const query = override ?? term;
|
||||
if (!addon || !query) {
|
||||
addon?.clearDecorations();
|
||||
setCount({ index: -1, total: 0 });
|
||||
return;
|
||||
}
|
||||
if (forward) addon.findNext(term, SEARCH_OPTS);
|
||||
else addon.findPrevious(term, SEARCH_OPTS);
|
||||
if (forward) addon.findNext(query, SEARCH_OPTS);
|
||||
else addon.findPrevious(query, SEARCH_OPTS);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -79,9 +80,14 @@ export function SearchBar({
|
||||
ref={inputRef}
|
||||
value={term}
|
||||
onChange={(e) => {
|
||||
setTerm(e.target.value);
|
||||
const value = e.target.value;
|
||||
setTerm(value);
|
||||
if (!value) {
|
||||
setCount({ index: -1, total: 0 });
|
||||
if (surfaceId) getSearch(surfaceId)?.clearDecorations();
|
||||
} else {
|
||||
run(true, value); // search-as-you-type
|
||||
}
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
|
||||
Reference in New Issue
Block a user