You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(terminal): break soft wraps after erase above clears a row - #4828
Break the soft wrap into the next row when ED 1 or DECSED 1 clears the cursor row. Partial erases and selective erases that leave protected text keep the wrap.
Rebuilt libghostty-vt with Zig 0.17.1. The regression tests check selection and copied text against the rebuilt WASM.
Workflow syntax, generated files, typecheck, build and the full unit suite passed. The check fast report was invalidated when the changes were committed mid-run. The tested file contents match the commit, and the focused tests also passed after committing.
bun run check run --build -- bun scripts/terminal-copy-off-regression.ts passed with Chromium, herdr 0.9.3 and the Rust PTY host. The full integration and browser suites were skipped.
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Fixed terminal selection and copying so clearing the cursor’s entire row with an erase-above command no longer joins the following row to it.
Corrected soft-wrap handling after erase and line-feed operations. Rows now retain their wrap when content remains, and the following row is separated when the erase clears the cursor’s entire row.
The erase-ends-wrap.patch updates erase-above handling when it clears the cursor’s entire row. Tests check the following row’s wrap state and selection text, including cases with wide characters and remaining text to the right of the cursor.
The patch resets wrap state when erase-above reaches the end of a wrapped cursor row and the protection and remaining-text conditions are met. Build comments and the expected output hash are updated.
Wrapping and selection regression checks src/lib/terminalReflow.test.ts, changelog.d/terminal-erase-above-wrap.md, THIRD_PARTY_NOTICES.md
Tests check following-row text, wrap state, wrapped range, and selection text for ED 1 and DECSED 1 cases. The changelog and third-party notice describe the related behavior.
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: soft wraps are broken after an erase-above command clears a row. The changeset adds Screen.cursorResetWrapContinuation, updates the erase-ends-wrap patch, changelog, a…
Description check
The description follows the template. It has a Change section that describes the problem and resulting behavior, and it links the issue #4782. It also has a Validation section that lists the commands …
Linked Issues check
[#4782] Coding requirements, as stated in the issue, are: (1) extend scripts/ghostty-vt/erase-ends-wrap.patch so ED 1 and unprotected DECSED 1 end the soft wrap when they clear the cursor row; (2) reb…
Out of Scope Changes check
All reviewed changes support the linked objective. scripts/ghostty-vt/erase-ends-wrap.patch and its Terminal.zig index metadata implement the wrap reset. src/lib/terminalReflow.test.ts covers the new …
Full details: Title check
Explanation
The title names the main change: soft wraps are broken after an erase-above command clears a row. The changeset adds Screen.cursorResetWrapContinuation, updates the erase-ends-wrap patch, changelog, and regression tests for ED 1 and DECSED 1. The title is specific and matches the linked issue #4782.
Full details: Description check
Explanation
The description follows the template. It has a Change section that describes the problem and resulting behavior, and it links the issue #4782. It also has a Validation section that lists the commands run and their results. It does not state which checks were skipped beyond the full integration and browser suites, and it says the check fast report was invalidated. These gaps are minor. The description is mostly complete.
Full details: Linked Issues check
Explanation
[#4782] Coding requirements, as stated in the issue, are: (1) extend scripts/ghostty-vt/erase-ends-wrap.patch so ED 1 and unprotected DECSED 1 end the soft wrap when they clear the cursor row; (2) rebuild shared/ghostty/ghostty-vt.wasm; (3) restore two assertions in src/lib/terminalReflow.test.ts.
Requirement (1): The patch summary shows a new Screen.cursorResetWrapContinuation helper. It is called from erase-display-above when the erase reaches the cursor row's end and no protected text remains. This matches the whole-row ED 1 and unprotected DECSED 1 case. Partial erases and protected-text cases keep the wrap, as the PR description states.
Requirement (3): terminalReflow.test.ts has expanded ED 1 and unprotected DECSED tests. They check that the following row is unwrapped, check its text and wrapped range, and check selection text. A test also confirms that ED 1 keeps the wrap when text remains right of the cursor.
Requirement (2): shared/ghostty/ghostty-vt.wasm is excluded from review by the rule !**/*.wasm. The WASM contents were not inspected. The result rests on the patch and test changes, which were reviewed, and on the PR description stating the rebuild and passing regression checks.
Full details: Out of Scope Changes check
Explanation
All reviewed changes support the linked objective. scripts/ghostty-vt/erase-ends-wrap.patch and its Terminal.zig index metadata implement the wrap reset. src/lib/terminalReflow.test.ts covers the new behavior. scripts/ghostty-vt/build.sh updates the patch description and the expected build SHA-256, which follows from the patch change. THIRD_PARTY_NOTICES.md updates the patch description to match. changelog.d/terminal-erase-above-wrap.md records the fix. Tests for wide-character final-column erasure extend the same ED 1 behavior. No unrelated change was found in the reviewed summary.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 7d1d71a and 096e9b2.
Files ignored due to path filters: 1
shared/ghostty/ghostty-vt.wasm is excluded by !**/*.wasm
Files selected for processing: 5
THIRD_PARTY_NOTICES.md
changelog.d/terminal-erase-above-wrap.md
scripts/ghostty-vt/build.sh
scripts/ghostty-vt/erase-ends-wrap.patch
src/lib/terminalReflow.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
…s a row whose wrap already ended
An earlier ED 1 can reset the cleared row's own wrap flag while the row
below still continues it; the whole-row erase now ends that continuation
too. Rebuilt ghostty-vt.wasm with Zig 0.17.1.
Thanks @iyuzhang, this is a clean fix with a reproducible WASM: an independent Zig 0.17.1 rebuild of your head was byte-identical to the shipped ghostty-vt.wasm, and three of the new tests fail on main's WASM.
Reviews (an omo gate review and a Codex review) both reproduced one remaining case, which I fixed on your branch in 205f07d:
An earlier erase above can reset the cleared row's own wrap flag while the next row keeps wrap_continuation (e.g. abcdefgh\x1b[2;1H\x1b[1J\x1b[1;1HXY\x1b[1;5H\x1b[1J in 5 columns). The whole-row ED 1 / DECSED 1 now also ends the next row's continuation, so the next row no longer selects or copies as part of the erased one. The patch, the rebuilt WASM (sha256 ef5b5329…, recorded in build.sh) and a test for both ED 1 and DECSED 1 are in that commit.
I also merged main into the branch (no force push). bun run check fast passed.
Merged through pr-merge at head 39f971265. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit said it did not review (a limit or a skip) since this head.
main moved but untouched: merged without update. Its new commits up to f97aa8006 change no file of this pull request, none imported by one, nothing that decides which checks run, and no core path.
Outside contributor's fix/test PR, merged under the owner's standing rule for external fix PRs that change no feature, UI, setting or HTTP/WS contract. Reviews: one omo gate review and one Codex adversarial review (gpt-6.2-sol-fast, xhigh, team proxy) of the contributor's head; both reproduced one MEDIUM (a row whose wrap an earlier erase had ended kept the next row's continuation), fixed by the maintainer in 205f07d with a rebuilt WASM (Zig 0.17.1). The gate review rebuilt the contributor's WASM byte-identically. CodeRabbit did not review the latest head. Reproduced on main: 3 new tests fail on main's WASM.
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
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.
Change
Break the soft wrap into the next row when
ED 1orDECSED 1clears the cursor row. Partial erases and selective erases that leave protected text keep the wrap.Fixes #4782.
Validation
check fastreport was invalidated when the changes were committed mid-run. The tested file contents match the commit, and the focused tests also passed after committing.bun run check run --build -- bun scripts/terminal-copy-off-regression.tspassed with Chromium, herdr 0.9.3 and the Rust PTY host. The full integration and browser suites were skipped.