editor: Fix folding for unindented multiline strings and comments#50049
Merged
smitbarmase merged 2 commits intozed-industries:mainfrom Mar 19, 2026
Merged
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @ryan-m-walker on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Contributor
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
6bea4ad to
09991e1
Compare
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 20, 2026
…d-industries#50049) Closes zed-industries#5057 ## Summary The indent-based code fold detection does not account for lines inside multiline strings or block comments that have less indentation than the surrounding code. This causes the fold scanner to think the enclosing block ends prematurely. For example, folding `fn main()` here would fail because the raw string content at indent level 0 gets treated as the end of the function body: ``` rust fn main() { let s = r#" unindented content "#; } ``` This PR checks whether a low-indent line falls inside a string or comment override region and skips it if so. This works across all languages that define `@string` or `@comment` overrides in their `overrides.scm`. ## Before https://github.com/user-attachments/assets/a08e6bf8-4f25-4211-8a46-8f6da7e49247 ## After https://github.com/user-attachments/assets/cd5b36db-6d4d-420b-9d60-79f9fad8638e ## Test Plan - Added `test_fold_with_unindented_multiline_raw_string` - Added `test_fold_with_unindented_multiline_block_comment` - All existing fold tests pass - Manually tested both Rust and Python examples Release Notes: - Fixed code folding incorrectly collapsing when multiline strings or block comments contained unindented content
toshmukhamedov
pushed a commit
to toshmukhamedov/zed
that referenced
this pull request
Mar 20, 2026
…d-industries#50049) Closes zed-industries#5057 ## Summary The indent-based code fold detection does not account for lines inside multiline strings or block comments that have less indentation than the surrounding code. This causes the fold scanner to think the enclosing block ends prematurely. For example, folding `fn main()` here would fail because the raw string content at indent level 0 gets treated as the end of the function body: ``` rust fn main() { let s = r#" unindented content "#; } ``` This PR checks whether a low-indent line falls inside a string or comment override region and skips it if so. This works across all languages that define `@string` or `@comment` overrides in their `overrides.scm`. ## Before https://github.com/user-attachments/assets/a08e6bf8-4f25-4211-8a46-8f6da7e49247 ## After https://github.com/user-attachments/assets/cd5b36db-6d4d-420b-9d60-79f9fad8638e ## Test Plan - Added `test_fold_with_unindented_multiline_raw_string` - Added `test_fold_with_unindented_multiline_block_comment` - All existing fold tests pass - Manually tested both Rust and Python examples Release Notes: - Fixed code folding incorrectly collapsing when multiline strings or block comments contained unindented content
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 23, 2026
…d-industries#50049) Closes zed-industries#5057 ## Summary The indent-based code fold detection does not account for lines inside multiline strings or block comments that have less indentation than the surrounding code. This causes the fold scanner to think the enclosing block ends prematurely. For example, folding `fn main()` here would fail because the raw string content at indent level 0 gets treated as the end of the function body: ``` rust fn main() { let s = r#" unindented content "#; } ``` This PR checks whether a low-indent line falls inside a string or comment override region and skips it if so. This works across all languages that define `@string` or `@comment` overrides in their `overrides.scm`. ## Before https://github.com/user-attachments/assets/a08e6bf8-4f25-4211-8a46-8f6da7e49247 ## After https://github.com/user-attachments/assets/cd5b36db-6d4d-420b-9d60-79f9fad8638e ## Test Plan - Added `test_fold_with_unindented_multiline_raw_string` - Added `test_fold_with_unindented_multiline_block_comment` - All existing fold tests pass - Manually tested both Rust and Python examples Release Notes: - Fixed code folding incorrectly collapsing when multiline strings or block comments contained unindented content
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.
Closes #5057
Summary
The indent-based code fold detection does not account for lines inside multiline strings or block comments that have less indentation than the surrounding code. This causes the fold scanner to think the enclosing block ends prematurely.
For example, folding
fn main()here would fail because the raw string content at indent level 0 gets treated as the end of the function body:This PR checks whether a low-indent line falls inside a string or comment override region and skips it if so. This works across all languages that define
@stringor@commentoverrides in theiroverrides.scm.Before
Screen.Recording.2026-02-24.at.7.45.23.PM.mov
After
Screen.Recording.2026-02-24.at.7.44.27.PM.mov
Test Plan
test_fold_with_unindented_multiline_raw_stringtest_fold_with_unindented_multiline_block_commentRelease Notes: