non-bracket outer framing#205
Open
Felix-Kettnaker wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
support non_bracket nodes without a closing delimiter
What
Adds an opt-in
non_bracket_node.outer_framingoption (defaulttrue). Setting it tofalsestops anon_bracketnode's format range from climbing to its parent's sibling when the node itself has no sibling on that side.Why
search.rangeframes anon_bracketnode by its surrounding siblings, falling back to the parent's sibling when the node has none:This is correct for languages whose blocks have an explicit closing delimiter token (e.g. Lua's
then ... end, where the delimiter is a sibling). But indentation-based languages have no closing token (Python, GDScript, CoffeeScript, …). A block that is the last child of its parent then has nonext_sibling, so the fallback grabs the following statement — the join range extends over it and swallows it. This currently makes it impossible to support split/join of:-introduced indented bodies.Change
With
outer_framing = false, a missing side uses the node's own range instead of the parent's sibling.Backward compatibility
Purely additive and opt-in —
outer_framingdefaults totrue, so framing is byte-for-byte unchanged for every existing preset. Verified against an existingnon_bracketlanguage (Lua, round-trips with a following statement intact) and bracket presets (Python lists/dicts).Example
A
non_bracketblock preset withouter_framing = falseon Python'sblock:Before (join swallows the next statement):
After:
Notes
Language-independent — this is the missing piece for split/join of indentation-delimited blocks in general. A companion GDScript preset PR uses it to toggle one-line
if/for/while/function bodies, but the flag is useful to any such language preset.Tests
The flag needs a configured language to exercise through the test harness; its behavior is covered by a later GDScript preset modification PR (which needs the original GDScript template first), which uses
outer_framing = falsefor statement bodies. I can also fold a test in here (e.g. demonstrating it on Python'sblock) if preferred.