Skip to content

Conversation

@gtanner
Copy link
Contributor

@gtanner gtanner commented Sep 27, 2025

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 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 #4039

…#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
@gtanner
Copy link
Contributor Author

gtanner commented Sep 27, 2025

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.

@github-actions
Copy link
Contributor

Test Results

175 tests  ±0   175 ✅ ±0   1s ⏱️ ±0s
 21 suites ±0     0 💤 ±0 
 21 files   ±0     0 ❌ ±0 

Results for commit f2ecf9f. ± Comparison against base commit 3ab54ab.

@gtanner
Copy link
Contributor Author

gtanner commented Sep 28, 2025

Did some testing and this does not really fix the problem, will need to take a better look at this

@gtanner gtanner changed the title Fix text search unable to find last file in folder (#4039) [DRAFT] Fix text search unable to find last file in folder (#4039) Sep 28, 2025
@seangoodvibes seangoodvibes marked this pull request as draft September 28, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text search does not work for the last item in a folder

1 participant