project: Use `checked_sub` for next/previous in search history (#34408)

Use `checked_sub` instead of checking for bounds manually. Also greatly
simplifies the logic for `next` and `previous`. Removing other manual
bounds checks as well

Release Notes:

- N/A
bd78f2c493tidely committed on 7/15/2025, 2:42:37 PM· committed by GitHubparentd1abba0
2 files changedLine totals unavailable