Skip to content

Keep a block's brackets when its folds merge by lines - #100

Merged
sidkmenon merged 1 commit into
tui-fold-line-countsfrom
fold-merge-keeps-syntax
Oct 7, 2026
Merged

sidkmenon merged 1 commit into
tui-fold-line-countsfrom
fold-merge-keeps-syntax

Conversation

@sidkmenon

Copy link
Copy Markdown
Contributor

Changes what diffr emits: more folds carry syntax. No schema change; draft until the output change is reviewed.

A block holding one statement folds twice over the same lines: the block (shared query, with @fold.open/@fold.close) and the statement (context query, no opener). merge_by_lines keeps the innermost node's syntax, which is the statement's None, so the merged fold lost its brackets. Frontends draw rails and bracket highlights from syntax, so every one-statement for/if body had no rail. The merged fold now keeps the other node's opener and closer when its own node has none; range, indent, owner and pairing are unchanged.

Seen in reviewStructuralDiff.ts (review @ 38a74d5fe): the for bodies at lines 119, 123 and 124 now carry syntax.

Validation: cargo test --workspace passes; cargo fmt --check clean. Extended two_queries_folding_the_same_lines_make_one_fold to assert the merged fold keeps the block's braces; it fails without the fix.

AI assistance: written with Claude Code.

A block holding one statement folds twice over the same lines: the block
from the shared query, with its opener and closer, and the statement from
the context query, with none. merge_by_lines kept the innermost node's
syntax, the statement's None, so the fold lost its brackets and frontends
drew no rail for it, as for every one-statement `for` body. The merged
fold now keeps the merged node's opener and closer when its own node has
none.

AI-assisted: Claude Code.
Agent-Session: 3c0a7f53-4e2b-4d6b-b99f-471c7e752571
@sidkmenon
sidkmenon force-pushed the fold-merge-keeps-syntax branch from f763846 to addbc3b Compare October 7, 2026 11:30
@sidkmenon
sidkmenon changed the base branch from main to tui-fold-line-counts October 7, 2026 11:30
@sidkmenon sidkmenon mentioned this pull request Oct 7, 2026
@sidkmenon
sidkmenon added this pull request to stack #101 October 7, 2026 11:32
@sidkmenon
sidkmenon marked this pull request as ready for review October 7, 2026 11:34
@sidkmenon
sidkmenon merged commit 5597875 into main Oct 7, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant