Skip to content

fix: searching checks both item name and display name#1260

Open
lucasser wants to merge 1 commit intorefinedmods:developfrom
lucasser:fix/GH-1259/search-for-display-name
Open

fix: searching checks both item name and display name#1260
lucasser wants to merge 1 commit intorefinedmods:developfrom
lucasser:fix/GH-1259/search-for-display-name

Conversation

@lucasser
Copy link
Copy Markdown
Contributor

@lucasser lucasser commented Mar 5, 2026

Added an itemName and a name variable to AbstractGridResource

If there is a stack of paper named "dinnerbone"
To get the item name "Paper" use resource.getItemName()
To get the display name "dinnerbone" use resource.getDisplayName()

GridQueryParser.parseLiteral() checks both itemName and displayName.

@lucasser lucasser force-pushed the fix/GH-1259/search-for-display-name branch 3 times, most recently from 1f783e1 to 024ca03 Compare March 5, 2026 16:49
@lucasser lucasser force-pushed the fix/GH-1259/search-for-display-name branch from 024ca03 to 04c4c37 Compare March 21, 2026 23:40
@raoulvdberge
Copy link
Copy Markdown
Contributor

raoulvdberge commented Mar 25, 2026

This would fix #1259, right?

@raoulvdberge
Copy link
Copy Markdown
Contributor

I'm not really fan of this PR, it introduces 3 variants of "names" in the code. And I have no idea how this fixes the problem of RS searching on the registry name "minecraft:paper", like mentioned in the original issue? Is that something that is fixed here? I see getName on Item is still being used.

@lucasser
Copy link
Copy Markdown
Contributor Author

Yes, it solves #1259
This will keep track of two different names, the item registry id/base item name, and the display name.
In most cases the two are the same, unless the item gets renamed.
The parser

        return (repository, resource) -> normalize(resource.getItemName()).contains(normalize(node.token().content()))
            || normalize(resource.getDisplayName()).contains(normalize(node.token().content()));

looks at both names. So if you have a renamed piece of paper it'll come up when you search paper (The current behaviour, useful if you are sorting through renamed Apotheosis gear for example) but also when you search for its name

@raoulvdberge
Copy link
Copy Markdown
Contributor

Question, in your PR description you mention:

To get the item name "Paper" use resource.getItemName()
To get the display name "dinnerbone" use resource.getDisplayName()

But in the message above, you talk about the registry name. That is not mentioned in your PR description, it's a bit confusing.

I would probably change the logic a bit:

  • Return a Set<String> instead of adding more "getName"-esque methods (these "getName"-esque methods are not always applicable to all resource types)
  • Search on the item name, display name, and registry ID.

@lucasser lucasser force-pushed the fix/GH-1259/search-for-display-name branch 2 times, most recently from b9083b8 to 2612e67 Compare March 25, 2026 09:56
@raoulvdberge
Copy link
Copy Markdown
Contributor

Could you rebase on the latest develop please?

@raoulvdberge
Copy link
Copy Markdown
Contributor

Also, please create these lists in the constructor. We don't want a bunch of list allocations each time you search something..

@raoulvdberge raoulvdberge added this to the v2.0.x milestone Apr 16, 2026
@lucasser lucasser marked this pull request as draft April 17, 2026 08:30
@lucasser lucasser force-pushed the fix/GH-1259/search-for-display-name branch 2 times, most recently from cf18140 to b28d4fd Compare April 17, 2026 08:58
@lucasser lucasser marked this pull request as ready for review April 17, 2026 08:59
@lucasser lucasser force-pushed the fix/GH-1259/search-for-display-name branch from 17cd4db to f2f65ff Compare April 17, 2026 09:51
@lucasser
Copy link
Copy Markdown
Contributor Author

Done


@ParameterizedTest
@ValueSource(strings = {"dirt", "Dirt", "DiRt", "Di", "irt", "test", "TeSt"})
void testNameQueryRenamedItems(final String query) throws GridQueryParserException {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work, the test setup hasn't changed? What does this test add

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It tests for the renamed search. assertThat(predicate.test(repository, new R(List.of("Dirt", "test")))).isTrue(); has been renamed to test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in the item used in that assert has been renamed to test, and should show up for all the search strings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just consolidate this in the other query test.

Comment thread CHANGELOG.md Outdated
@lucasser lucasser force-pushed the fix/GH-1259/search-for-display-name branch from f2f65ff to b17e597 Compare April 17, 2026 15:02
@lucasser lucasser requested a review from raoulvdberge April 17, 2026 15:04

@ParameterizedTest
@ValueSource(strings = {"dirt", "Dirt", "DiRt", "Di", "irt", "test", "TeSt"})
void testNameQueryRenamedItems(final String query) throws GridQueryParserException {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just consolidate this in the other query test.

);
case ID -> assertThat(repository.getViewList())
.extracting(GridResource::getName)
.extracting(resource -> resource.getSearchableNames().getLast())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why getLast here? instead of hoverName

Comment thread CHANGELOG.md Outdated
@lucasser
Copy link
Copy Markdown
Contributor Author

From one of the review comments:

I renamed them to getSearchableNames and getHoverName. getHoverName is only used in tests to check if the items are correct. Should i just remove it then and have the tests check getSearchableNames().last instead?

Do i keep the method just for tests, or get rid of it?

@lucasser lucasser force-pushed the fix/GH-1259/search-for-display-name branch from 7912eb3 to 9241872 Compare April 19, 2026 17:22
@lucasser lucasser requested a review from raoulvdberge April 19, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants