editor: Include closing delimiter on same line when folding#50090
Conversation
When using indent-based folding (the default), collapsed folds for brace-delimited languages showed the closing delimiter on a separate line (e.g. / ). Now the fold range extends through the newline and leading whitespace before a closing , , or , so the collapsed display is a single line: . Whitespace-sensitive languages (Python) are unaffected because their terminating lines do not start with a closing delimiter. Closes zed-industries#50002
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Overall, it's not very clear why brackets have to be a part of all the heuristic code — if we can solve that and the rest of the comments, would be great.
Address review feedback: - Replace hardcoded `}`, `)`, `]` check with `scope.brackets()` from the language's bracket pair config. A `line_starts_with_closing_bracket` helper encapsulates the detection logic. - Handle closing tags (`</`) separately since they aren't represented in bracket pair configs. Fall back to common delimiters when no language is set. - Extract duplicated blank-line-skipping logic into a `last_non_blank_row` closure. - Remove the manual `chars_at` loop; use `line_indent_for_buffer_row` and `take_while` instead.
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Thank you for the style fixes, we still use hardcoded values it seems, so things have not changed too much, globally.
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Great, looks like the remaining questions are about the test code only.
…-industries#50090 rust_lang() now has BracketPairConfig ({}, [], (), <>, "") so fold tests don't need rust_language_with_brackets_and_overrides() anymore. Split test_fold_action into with-language and without-language variants. Raw string and block comment fold tests also switched to rust_lang().
|
Looking to the CI errors now |
…ed-industries#50090) The bracket pairs added to rust_lang() combined with scope.brackets()-only detection now places closing delimiters on the fold line. Update two assertions in folding_ranges tests to match the new behavior.
Thank you for all the help and guidance!! |
|
@Dnreikronos How can it be configured to display like this? |
Hi, mate! |



CLOSES: #50002
When using indent-based folding (the default,
document_folding_ranges = Off),collapsed folds in brace-delimited languages displayed the closing delimiter on
a separate line:
fn b() {⋯
}
This extends the fold range in
crease_for_buffer_rowto include the trailingnewline and leading whitespace before a closing
},), or], producingthe expected single-line display:
fn b() {⋯}
Whitespace-sensitive languages like Python are unaffected — their terminating
lines don't start with a closing delimiter, so the existing behavior is
preserved.
Before you mark this PR as ready for review, make sure that you have:
Screenshots:

Before:
After:

Release Notes:
},),]) on the same line as the fold placeholder instead of on a separate line (#50002).