Fix Eat menu resetting after consuming food #38366
Merged
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.
Summary
SUMMARY: Bugfixes "Fix Eat menu resetting after consuming food"
Purpose of change
Fixes #36884
Fixes #38014
To fix the issue where the (E)at menu resets menu position after consuming items, if the menu has more than one category or has a filter.
Describe the solution
Apparently the inventory just needed an additional call to update() after setting the cached filter, introduced in #37538.
I honestly am not sure exactly what mechanism was causing the filter setting code to disrupt this, I found this solution through trial and error. I think the filter-setting code calling prepare_paging was invalidating the positions that were being set with the later call to select_position.
Describe alternatives you've considered
Continuing to arrange my food in small piles to avoid this very annoying bug.
Testing
Tested the various scenarios that would trigger this bug: multi-position food, filtered eat menu, and tested eating with and without multi-position sources and with and without filters, before and after.
Additional context
The inventory management code being dealt with here is really testing the limits of my abilities. Even though this is a one-line fix I would greatly appreciate some code review.