[DRAFT] Fix text search unable to find last file in folder (#4039)#4097
Draft
gtanner wants to merge 1 commit intoSynthstromAudible:communityfrom
Draft
[DRAFT] Fix text search unable to find last file in folder (#4039)#4097gtanner wants to merge 1 commit intoSynthstromAudible:communityfrom
gtanner wants to merge 1 commit intoSynthstromAudible:communityfrom
Conversation
…#4039) Bug: The alphanumeric text search could not find the last file in any folder. When typing the first letters of the last file's name (e.g., 'X' for 'Xylophone'), it would not appear in search results. Root cause: In predictExtendedText(), when searching for a prefix like 'X', the code appends '~' to create 'X~' and uses binary search to find where this would be inserted. For the last file, this correctly returns index == numElements. However, the condition 'i >= numElements' incorrectly treated this valid case as 'not found'. Fix: Changed the condition from 'i >= numElements' to 'i > numElements' at line 1412. This allows the valid case where i == numElements, which occurs when the last item matches the search prefix. The subsequent 'i--' then correctly selects the last file. Also fixed a similar bounds check issue in setFileByFullPath() at line 506, changing from 'i > numElements' to 'i >= numElements' for proper validation of exact file searches. Fixes SynthstromAudible#4039
Author
|
NOTE: I wanted create and run the unit tests for this but ran into problems since I am on a 64 bit OS. I will build and load this on my deluge later to manually test and update the PR with the results. |
Contributor
Author
|
Did some testing and this does not really fix the problem, will need to take a better look at this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP: currently not working, needs some more investigation
Bug: The alphanumeric text search could not find the last file in any folder. When typing the first letters of the last file's name (e.g., 'X' for 'Xylophone'), it would not appear in search results.
Root cause: In predictExtendedText(), when searching for a prefix like 'X', the code appends
~to createX~and uses binary search to find where this would be inserted. For the last file, this correctly returnsindex == numElements. However, the conditioni >= numElementsincorrectly treated this valid case as 'not found'.Fix: Changed the condition from
i >= numElementstoi > numElementsat line 1412. This allows the valid case where i == numElements, which occurs when the last item matches the search prefix. The subsequenti--then correctly selects the last file.Also fixed a similar bounds check issue in setFileByFullPath() at line 506, changing from
i > numElementstoi >= numElementsfor proper validation of exact file searches.Fixes #4039