Skip to content

Commit

Permalink
fix: re-run search if a file is reloaded from disk
Browse files Browse the repository at this point in the history
Fixes #444
  • Loading branch information
connor4312 committed Feb 2, 2024
1 parent 19364d7 commit 87e8605
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion media/editor/findWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const FindWidget: React.FC = () => {
clearTimeout(timeout);
}
};
}, [query, JSON.stringify(queryOrError), isUncapped, isCaseSensitive, isBinaryMode, edits.length - safeReplacedEditsLen.current]);
}, [query, JSON.stringify(queryOrError), isUncapped, isCaseSensitive, isBinaryMode, edits.length - safeReplacedEditsLen.current, results.outdated]);

const closeWidget = () => {
const prev = previouslyFocusedElement.current;
Expand Down
4 changes: 4 additions & 0 deletions media/editor/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ export const searchResults = atom<SearchResultsWithProgress>({
: { progress: msg.data.progress, capped: msg.data.capped, results: prev.results.concat(msg.data.results) }
);
});

registerHandler(MessageType.ReloadFromDisk, () => {
fx.setSelf(prev => prev instanceof DefaultValue ? prev : ({ ...prev, outdated: true }));
});
}
],
});
Expand Down
1 change: 1 addition & 0 deletions shared/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface SearchResultsWithProgress {
results: SearchResult[];
progress: number;
capped?: boolean;
outdated?: boolean;
}

export interface SearchProgressMessage {
Expand Down

0 comments on commit 87e8605

Please sign in to comment.