Repository navigation
fix: keep the next line left-aligned when a wrapped line fills the width exactly - #39
Merged
Merged
Conversation
…ui.rs left one Position::new(...) call split across four lines, and rustfmt wants it on one line. src/ui.rs:90 is now Some(Position::new(x + col, prompt_area.y + line_no as u16)). Nothing else changed. cargo is not on PATH here, so I ran rustfmt through nix with edition 2024 (from Cargo.toml): `nix run nixpkgs#rustfmt -- --edition 2024 --check src/*.rs` passed with no diffs
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.
Intent
thokr an another pr
The fix referred to: a thokr bug on main where a wrapped line that fills the width exactly pushes the next line one space right (
src/layout.rs:33).What Changed
layout::wrap_charsnow lets the first space after a full line hang one cell past the edge. Before, that space wrapped onto the next line and pushed the next word one column right. A second space after a full line still wraps. The doc comment and the width/column invariants in the tests now allow this one extra cell.render_runninginsrc/ui.rsmakes the prompt's text area one column wider, capped at the terminal's right edge. A hanging space, including a mistyped one shown in red, is drawn instead of clipped. The cursor position is taken from the samex.Risk Assessment
✅ Low: The change is small. It lets one space hang past a full line and widens the render area by one margin column so that space can be drawn. The fix-round change draws the hanging cell, shows the mistyped space and keeps the cursor at the same position, and the new snapshots cover it.
Testing
Built thokr at the base and target commits and drove the real TUI in tmux with isolated HOME directories. On base, the bug shows up: lines after an exactly-full line start one column right, at 15 and 80 columns. On the target, every line is left-aligned. The mistyped hanging space shows as a red '·' and the pace caret stays visible on the hanging cell. A second space still wraps, as designed. Narrow terminals and a complete test run to the results screen work. The targeted layout and running-snapshot tests pass. The visual evidence is a screenshot of live before/after tmux captures rendered with their real ANSI colors.
Evidence: Before/after rendered HTML
Evidence: Exactly-full line, 15 cols (tmux capture)
Evidence: Mistyped hanging space (target build, ANSI)
Evidence: Pace caret on hanging space (target build, ANSI)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
src/ui.rs:73- The hanging space that wrap_chars now places at col == width is clipped by the renderer, so mistakes on it no longer show. render_running draws the prompt withParagraph::new(text).render(text_area, buf). It sets no Wrap, and text_area is exactlymax_chars_per_linewide (prompt_area.width - x_offset), so ratatui truncates every line to that width. The new 6-char line range (e.g.aaaaaat width 5, src/layout.rs:35) loses its last cell. Concrete case: prompt "aaaaa bbb ccccc dd" at 15 cols, user types "aaaaax". prompt_line emits a red '·' (INCORRECT) for idx 5, but that cell is cut off. The user sees nothing wrong, while the cursor jumps to the margin at x=10 and then to the next line. The pace caret (REVERSED) also disappears whenever it sits on a hanging space. Before this change, that space started the next line and the red '·' was visible. Fix: let the text area extend one column into the right margin when the prompt has more than one line (HORIZONTAL_MARGIN = 5 leaves room), e.g.width: prompt_area.width - x_offset + 1clamped to area. Then add a snapshot of a mistyped hanging space. The same invariant (a hanging cell must be drawable) applies to the cursor position at src/ui.rs:86-90, which already lands in the margin.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
Built base 1280cef and target c8a41c8 withnix shell nixpkgs#cargo nixpkgs#rustc nixpkgs#gcc -c cargo buildRanthokr -p 'aaaaa bbb ccccc dd'in a detached tmux session at 15x8 with a throwaway HOME, on both builds, and captured the pane with and without ANSI codesTypedaaaaa, thenaaaaa<space>, thenaaaaax(mistyped space) on the target build, and typedaaaaaxon the base buildRan--pace 6, typedaand waited 11s so the pace caret sat on the hanging space (both builds)80x24 run with the long 'it was the best of times...' prompt on both buildsEdge cases: promptaaaaa bbb ccccc(double space) at 15 cols,aaa bbat 11 cols (width 1) and 8 cols, and a full test run to the results screen at 60x20cargo test layout::andcargo test running_(targeted layout and snapshot tests)Rendered the before/after ANSI captures to HTML and took a screenshot withchrome-devtools-axi screenshot✅ **Document** - passed
✅ No issues found.
⏭️ **Lint** - skipped
src/ui.rs-cargois not on PATH in this environment, socargo fmt --checkandcargo clippy --all-targetsdid not run. Formatting and lint for src/layout.rs and src/ui.rs are unverified. The doc comment and code comment edits are comment-only and keep lines under 100 columns.✅ **Push** - passed
✅ No issues found.