feat: add smart left indent RFC8792 folding#282
Open
panva wants to merge 6 commits into
Open
Conversation
cabo
reviewed
May 14, 2026
Owner
cabo
left a comment
There was a problem hiding this comment.
Nice!
Sorry for nitpicking on the code.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Contributor
Author
No worries, I welcome the direction. |
cabo
reviewed
May 17, 2026
| rest = li[col..-1] | ||
| indent = left || columns - rest.size | ||
| if !left && li[-1] == "\\" | ||
| indent = left_indent || columns - rest.size |
Owner
There was a problem hiding this comment.
Hmm, makes me wonder whether there should be a smart_right (right-aligned, but not using more of the line to the left than smart indentation).
Contributor
Author
There was a problem hiding this comment.
possible in a follow up, and possibly after there's a test suite, this is getting to a point where changes could use a set of vectors to test with.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
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.
Adds a smart indentation variant for automated RFC 8792 folding.
The new
smartNfold option can be used in the same position asleftN(they are mutually exclusive), for example:{::include-fold69hardsmart2dry generated.json}Unlike
leftN, which uses a fixed continuation indentation,smartNcomputes the continuation indentation from the line being folded:This is useful for nested structured data such as JSON, where folded continuation lines should stay visually aligned with the surrounding nesting level.
Since you moved the docs to the wiki I'll leave those to you to update if this gets accepted.
Example input:
{ "outer": { "array": [ { "description": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "nested": { "token": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" } } ] } }With
fold69hardsmart2dry: