Collapsing of @if..else structures behaves differently in code and razor files
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
Consider this c# code:
```html
if (isFoo) {
doFoo();
}
else {
doBar();
}
```
Both the `if` and `else` blocks can be collapsed, separately. To collapse both one must collapse their parent scope.
Consider this identical razor code:
```html
@if (isFoo) {
doFoo();
}
else {
doBar();
}
```
If one collapses the `if` then the entire `if`..`else` structure is collapsed, instead of only the `if` block. (If one collapses the `else` then only the `else` block is collapsed, as expected.)
.net 7.0.410
vscode 1.91.1 (latest)
csharp extension 2.39.29 (latest)
Contributor guide
Research direction
Start by reproducing the folding behavior in the C# and Razor snippets from the issue using VS Code 1.91.1, .NET 7.0.410, and C# extension 2.39.29. The change is done when collapsing the Razor if block folds only that block, matching the behavior of the equivalent C# code, while else folding remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, vscode
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100