fix: searching checks both item name and display name#1260
fix: searching checks both item name and display name#1260lucasser wants to merge 1 commit intorefinedmods:developfrom
Conversation
1f783e1 to
024ca03
Compare
024ca03 to
04c4c37
Compare
|
This would fix #1259, right? |
|
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 |
|
Yes, it solves #1259 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 |
|
Question, in your PR description you mention:
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:
|
b9083b8 to
2612e67
Compare
|
Could you rebase on the latest |
|
Also, please create these lists in the constructor. We don't want a bunch of list allocations each time you search something.. |
cf18140 to
b28d4fd
Compare
17cd4db to
f2f65ff
Compare
|
Done |
|
|
||
| @ParameterizedTest | ||
| @ValueSource(strings = {"dirt", "Dirt", "DiRt", "Di", "irt", "test", "TeSt"}) | ||
| void testNameQueryRenamedItems(final String query) throws GridQueryParserException { |
There was a problem hiding this comment.
How does this work, the test setup hasn't changed? What does this test add
There was a problem hiding this comment.
It tests for the renamed search. assertThat(predicate.test(repository, new R(List.of("Dirt", "test")))).isTrue(); has been renamed to test.
There was a problem hiding this comment.
As in the item used in that assert has been renamed to test, and should show up for all the search strings
There was a problem hiding this comment.
Just consolidate this in the other query test.
f2f65ff to
b17e597
Compare
|
|
||
| @ParameterizedTest | ||
| @ValueSource(strings = {"dirt", "Dirt", "DiRt", "Di", "irt", "test", "TeSt"}) | ||
| void testNameQueryRenamedItems(final String query) throws GridQueryParserException { |
There was a problem hiding this comment.
Just consolidate this in the other query test.
| ); | ||
| case ID -> assertThat(repository.getViewList()) | ||
| .extracting(GridResource::getName) | ||
| .extracting(resource -> resource.getSearchableNames().getLast()) |
There was a problem hiding this comment.
Why getLast here? instead of hoverName
|
From one of the review comments:
Do i keep the method just for tests, or get rid of it? |
7912eb3 to
9241872
Compare
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.