Repository navigation
Fix history scrolling and preserve selection after deletion - #566
tomasmark79 wants to merge 6 commits into
Conversation
|
This is really great! Thank you 🙏 |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved critical and moderate issues remain in history traversal, memory use, deletion behavior, and notification rendering.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Fixes history navigation by adding full-list scrolling, viewport-preserving selection, deletion handling, documentation, and PTY regression coverage.
Changes:
- Adds indexed, non-wrapping navigation and page scrolling.
- Preserves selection and viewport across deletion, filtering, and resizing.
- Adds integration tests and man-page documentation.
| File | Summary and review findings |
|---|---|
test/src/test_scroll.py |
Adds PTY regression coverage for scrolling, resizing, deletion, filtering, and layouts. |
test/README-scrolling.md |
Documents integration-test execution. |
src/hstr.c |
Implements scrolling and selection management. Findings: uninitialized raw-history slots may cause crashes or invalid rendering (critical, 1 vote); inactive-view allocations may use avoidable memory (moderate, 2 votes); final-match deletion can misplace the selection row (moderate, 1 vote); duplicate deletion can skip entries (moderate, 1 vote); deletion notifications can be erased by selection redraw (moderate, 1 vote). |
man/hstr.1 |
Documents navigation and deletion behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // keep all matches, not just the first terminal-sized page. | ||
| unsigned capacity=MAX(hstr->history->rawCount, hstr->history->count); | ||
| capacity=MAX(capacity, hstr->favorites->count); | ||
| hstr_make_selection(pattern, hstr->history, capacity); |
| unsigned capacity=MAX(hstr->history->rawCount, hstr->history->count); | ||
| capacity=MAX(capacity, hstr->favorites->count); |
|
@tomasmark79 I just want you let you know that I really appreciate your contribution - still 👁️ it to make sure it is safe. Please stay tuned! Thanks you! |
|
Hi, I think it's fine. I'm using my own fork, so feel free to take your time with the installation process to ensure that it doesn't cause any problems. Personally, I use it and the project is very addictive overall, so the ability to move things around is something that makes it a must-have. Thank you for your hard work and for making this project a reality. |
9d72658 to
0d53a5d
Compare


HSTR currently limits interactive matches to the terminal height, so moving past the last visible row wraps to the beginning instead of reaching older commands. This change keeps the complete match list and scrolls a viewport through it.
prompt-bottomlayouts and terminal resizing.Includes man-page documentation and PTY integration tests (
python3 test/src/test_scroll.py /path/to/hstr, requirespyte). Tests use temporary history files and cover paging, boundaries, resizing, deletion, filtering, regex, empty lists, and all four prompt/help layouts. History persistence is unchanged. Raw-history construction now initializes and compacts skipped entries, and both matching passes guard null or empty commands. Three Unity regressions cover empty entries with and without timestamps, empty parsed zsh commands, and histories with no valid commands.Validation: built on NixOS; terminal regression suite passed; Unity suite reported 15 tests, 0 failures, 2 ignored. All three new history regressions fail before the fix and pass after it; a focused Valgrind run reports zero errors and zero lost bytes. The scrolling and deletion behavior was also verified interactively by the contributor.
Memory-check caveat: Valgrind reports existing leaks in history deletion and uninitialized-value diagnostics in regex matching. Both were reproduced against unpatched
520e79awith the same input, so this PR does not claim a clean Valgrind run or attempt unrelated memory-management fixes.Fixes #92. Fixes #456. Fixes #561.