File search: don't report shown elements as shown matches - #4236
File search: don't report shown elements as shown matches#4236iloveeclipse wants to merge 2 commits into
Conversation
|
Disclaimer : this is fully AI generated patch proposed by AI after review from #4233, which seem to work. I will let the tests run and mark it as a draft for now, as I will not have time to proceed. |
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
There was a problem hiding this comment.
Pull request overview
Fixes issue #3720 by reporting visible search matches/files accurately.
Changes:
- Adds model-based leaf and match counting.
- Updates result labels for limits and filters.
- Adds regression tests and increments the bundle version.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
SearchResultPageLabelTest.java |
Tests label counts and truncation. |
AllFileSearchTests.java |
Registers the new tests. |
IFileSearchContentProvider.java |
Defines counting APIs. |
FileTreeContentProvider.java |
Counts visible tree leaves and matches. |
FileTableContentProvider.java |
Counts table elements and matches. |
FileSearchPage.java |
Builds labels from provider counts. |
MANIFEST.MF |
Increments bundle version. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8c8766e to
9314f1f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (1)
bundles/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java:473
- The new calculation separating match-filtered results from element-limit truncation is not covered by the added label tests. Please add a case with an active match filter and a truncating element limit, asserting that the “matches filtered from view” count includes only filter-rejected matches while the limited qualifier reports the independently hidden matches.
int filteredOut = result.getMatchCount() - getUnfilteredMatchCount(result);
FileSearchPage#getLabel() compared the number of shown *leaf elements*
with the number of *matches* and rendered the result with the "showing
{1} of {2} matches" message. In the tree layout of a text search a leaf
is a matching line, and a line can contain more than one match, so the
label claimed that matches are hidden although everything was shown, and
the reported number was a line count and not a match count.
The content provider is the only component that knows what is really
shown, since it applies the element limit. It now tells the page whether
the element limit hides elements at all, and how many matches are
represented by the shown elements.
With that the page reports a truncated result only if the element limit
really hides something, and reports matches (not lines) in the "showing
{1} of {2} matches" message, while the "showing {1} of {2} files"
message keeps reporting files.
The counts are computed on the model instead of on the SWT widgets, so
the label is also correct if the viewer isn't populated yet, and the
widget traversal could be removed from the page. As before, the model
traversals stop at subtrees hidden by the element limit; truncation is
detected without any traversal as long as no element has more children
than the element limit allows, and the (linear) count of the shown
matches is only computed if elements are really hidden.
Matches hidden by match filters are now counted independently from the
element limit, so a truncated result is no longer reported as filtered.
The query of a search result shown by the file search page is not
necessarily a FileSearchQuery: clients (and NullSearchResult in the
tests) may show any AbstractTextSearchResult. The unguarded casts in the
tree content provider and in the page therefore fail with a
ClassCastException as soon as the tree layout is used, so they are
replaced by instanceof checks. The added label test restores the element
limit and the layout it found, since both are shared by all file search
pages via the dialog settings.
Fixes eclipse-platform#3720
Assisted-by: Github Copilot (Claude Opus 5)
a7eac5c to
a37b37f
Compare
FileSearchPage#getLabel() compared the number of shown leaf elements with the number of matches and rendered the result with the "showing {1} of {2} matches" message. In the tree layout of a text search a leaf is a matching line, and a line can contain more than one match, so the label claimed that matches are hidden although everything was shown, and the reported number was a line count and not a match count.
The content provider is the only component that knows what is really shown, since it applies the element limit. It now reports
The page uses those numbers to only report a truncated result if the element limit really hides something, and to report matches (not lines) in the "showing {1} of {2} matches" message and files in the "showing {1} of {2} files" message.
As the counts are computed on the model instead of on the SWT widgets, the label is also correct if the viewer isn't populated yet, and the matches hidden by match filters are now counted independently from the element limit. This also allows to remove the widget traversal from the page.
Fixes #3720
Assisted-by: Github Copilot (Claude Opus 5)
Agent explanation:
Root cause of #3720
In FileSearchPage.getLabel() :
Two different units are compared and an element count is rendered as a match count. Before commit 9cfdcbb (2024) that branch was dead code (it was guarded by viewer instanceof TableViewer while showLineMatches() requires the tree layout); that commit made it live, and since then the tree layout reports the number of matching lines as the number of shown matches. Because a line can hold several matches, the label claims results are hidden even when nothing is truncated — exactly "shown file count vs shown match count".
The PR #4233 commit keeps that structure and papers over it with a new message plus an O(lines × matches) recount on the UI thread every 500 ms.
Principle: the content provider is the only component that knows what is really shown (it owns the element limit), so let it report the numbers, computed on the model, not on the SWT widgets.
IFileSearchContentProvider
FileTreeContentProvider
FileTableContentProvider: shown/total element counts, and shown matches summed over the shown elements.
FileSearchPage.getLabel()
leafs.isTruncated(), i.e. only when the element limit really hides something → the false "showing 12 of 20 matches" is gone;Net: FileSearchPage −106/+51 lines, and the label logic has a single source of truth.