Add softwrapcolumn option to soft-wrap at a fixed column#4142
Open
ddaanet wants to merge 1 commit into
Open
Conversation
When softwrap is enabled, lines wrap at the edge of the pane. This adds a `softwrapcolumn` option that, when non-zero, wraps at that column instead, clamped to the pane width. It defaults to 0, preserving the current behavior of wrapping at the pane edge, and only takes effect when softwrap is enabled. The wrap width is tracked separately from the pane width (`wrapWidth` vs `bufWidth`), so the region between the wrap column and the pane edge is still cleared on every visual row and keeps colorcolumn and cursor-line highlighting spanning the full pane. Addresses micro-editor#2374.
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.
Summary
When
softwrapis enabled, lines wrap at the right edge of the pane. This adds asoftwrapcolumnoption that, when non-zero, wraps at that column instead — clamped to the pane width. It defaults to0, which preserves today's behavior of wrapping at the pane edge, and only takes effect whensoftwrapis on.This lets wrapped text line up with a fixed ruler (e.g.
colorcolumn 80) regardless of how wide the pane happens to be.Fixes #2374.
Design
0(off).0= wrap at the pane edge (unchanged);N= wrap at columnN. Same "off-sentinel" convention as other options.colorcolumn/scrollmargin.wordwrap. The wrap point becomesmin(softwrapcolumn, bufWidth); the existing word-boundary logic is unchanged.wrapindentapproach in Add wrapindent option to allow wrapping and hanging indents #3107, which had to rewrite that mapping).Implementation notes
The wrap width is tracked separately from the pane width (
wrapWidthvsbufWidth), so the "dead zone" between the wrap column and the pane edge is still cleared on every visual row and keepscolorcolumnand cursor-line highlighting spanning the full pane.Edge cases:
colorcolumnand cursorline still draw across the full pane width.Testing
make buildandmake testpass locally (go test ./internal/... ./cmd/...), including thenew
softwrap_test.gocases.