Repository navigation
Conversation
Implement hard wrap at input time, similar to vim's textwidth: when a non-whitespace character is entered past text-width, the affected line is broken at its softwrap wrap point and continues on the next line with the line's indentation, list marker (aligned under the item content, never a repeated marker) and comment token re-applied. Words are never split; a word too long to fit overflows until a space is entered past it. Only lines being edited are touched, and soft wrapping remains an independent display transform. The break point is computed by reusing the softwrap traversal (DocumentFormatter) with the width budget reduced on continuation rows for the continuation prefix, so the wrap points match what softwrap would display. The continuation-prefix resolver floors the line's leading whitespace, raises it to the tree-sitter indent when available, then appends the comment token (reusing continue-comments detection) and a list-marker delta. `enable` and `list-markers` are resolved per position through the innermost language layer (following injections), then the document language, then the global config. List-marker detection is configurable via the auto-pairs-style [editor.hard-wrap].list-markers option (bool or custom regex). The wrap applies as a second transaction composing into the same pending changeset as the insert, keeping a single undo step. Paste, completion/snippet inserts and Enter are intentionally unchanged. See docs/261010_hard_wrap.md for the full design.
gwicke
force-pushed
the
feature/hard-wrap
branch
from
October 10, 2026 22:24
49be4b6 to
6d9e946
Compare
This branch has not been deployed
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.
For-discussion implementation of #2274. Functional and working well for me, but NOT ready for merge yet. I am looking for feedback first, and there are some documented deferred / backlog items in the temporary design doc. To test, build
hxwith this patch, and add the following section to your config.toml:Implement hard wrap at input time, similar to vim's textwidth: when a non-whitespace character is entered past text-width, the affected line is broken at its softwrap wrap point and continues on the next line with the line's indentation, list marker (aligned under the item content, never a repeated marker) and comment token re-applied. Words are never split; a word too long to fit overflows until a space is entered past it. Only lines being edited are touched, and soft wrapping remains an independent display transform.
The break point is computed by reusing the softwrap traversal (DocumentFormatter) with the width budget reduced on continuation rows for the continuation prefix, so the wrap points match what softwrap would display. The continuation-prefix resolver floors the line's leading whitespace, raises it to the tree-sitter indent when available, then appends the comment token (reusing continue-comments detection) and a list-marker delta.
enableandlist-markersare resolved per position through the innermost language layer (following injections), then the document language, then the global config. List-marker detection is configurable via the auto-pairs-style [editor.hard-wrap].list-markers option (bool or custom regex).The wrap applies as a second transaction composing into the same pending changeset as the insert, keeping a single undo step. Paste, completion/snippet inserts and Enter are intentionally unchanged.
See docs/261010_hard_wrap.md for the full design.