Repository navigation
Conversation
Typing on ("beac" to "beach") or adding an ext: keeps the matches that
still fit instead of walking the folder again, when the last search wasn't
cut short by the limit. Widening, or a change of folder, looks again.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
[Medium impact] The change is limited to the file browser's folder-search workflow. The PR appears safe to merge, with small follow-up fixes recommended for counts, Unicode extensions, and comments. Findings
SummarySearches can now reuse completed results when a new query only narrows the matches.
Three small issues remain: unfinished folder counts are dropped, some Unicode extensions match differently, and the new helper's comments describe its contract backward. Reviews (1) · Last reviewed commit: "Narrow a search from what it already fou..." · Reviewed by Greptile |
| setLoading(false); | ||
| emit loaded(); | ||
| return; |
There was a problem hiding this comment.
Folder counts stop updating. Typing another character after a search finishes can cancel folder counts that are still running.
reload() changes m_generation, so their results are discarded, but this early return never starts countFolders(generation) again. On large or slow folders, the remaining results can show no item counts until another full reload. Restart the unfinished counts before returning.
| const SearchFilter wanted(query); | ||
| QVector<Entry> kept; | ||
| for (const Entry &e : std::as_const(m_entries)) | ||
| if (wanted.matches(QFileInfo(e.path).fileName(), e.isDir, e.extension)) |
There was a problem hiding this comment.
Unicode extensions match differently. This passes
e.extension, which entryFor() has already uppercased, into a check that lowercases it again. That round trip changes some Unicode letters: a file named notes.ß stores SS, so narrowing notes to notes ext:ß incorrectly removes it, while a fresh search finds it. Use the original suffix from QFileInfo(e.path) rather than the display extension.
| // Whether every match of the search `from` is also a match of `to`, so | ||
| // typing on ("beac" to "beach", or adding an ext:) can narrow what's | ||
| // already found instead of looking again. |
There was a problem hiding this comment.
Narrowing contract is backward. The comment says every
from match must also match to, but the function requires the reverse: every to match must already match from. For example, beacon matches beac, but not beach, even though this pair correctly returns true. Reverse this description and the matching comment above SearchFilter::narrowedBy so future filters follow the right rule.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Typing on in the search (
beactobeach) or adding anext:now keeps the matches that still fit, instead of walking the folder and everything below it again for each keystroke.It only does this when the last search finished and wasn't cut short by the 1000-match limit, in the same folder with the same hidden-files and chooser-filter settings. Deleting characters, a different extension, or a new folder search again as before.
FolderModel::narrows()decides whether one query's matches are a subset of another's; it's tested, along with the model answering from what it found.bin/testpasses.Note for anything that adds query words whose matches don't only shrink as text is added (e.g. a
dupes:filter):SearchFilter::narrowedByis where to say so.🤖 Generated with Claude Code