Fix the dotted line for multiline condition in else if#48534
Conversation
|
an we have test for: if (foo)
{
}
else
if (bar)
{
}? |
|
I don't know to unit test this. I can run with F5 and see what's the behavior and add screenshot though. But surely we would need to find a way to unit test. For the case of: I haven't yet tested what is the behavior, but I think the dotted line would be in the "if", is that the expected behavior? |
Yes. |
|
needs test (esp. showing the difference for single-line conditionals vs multi-line conditionals. |
Need some guidance on how to test this. |
We should have some existing block structure tests that validate the ranges for these. |
The tests I found are referenced in the PR description, but the existing expected result in it implies that the bug should exist for single-line else if.
I can simply update |
|
To be more clear: roslyn/src/EditorFeatures/CSharpTest/Structure/BlockSyntaxStructureTests.cs Lines 287 to 302 in cf55f3a The previous test shows the hint at the start of the "if" not the "else". How the indent guide shows in the "else"? Where the results of GetHintSpan are altered? |
We are responsible for the data on our side. VS is responsible for the presentation. if things are fixed onour end, that's sufficient. if it regresses again, we can move to VS side. Can you please add a test here? |
|
@CyrusNajmabadi Thanks for clarifying. I added tests, but I'd still recommend that you give a quick look to the internal implementation in VS side.
|
|
Ping @CyrusNajmabadi |

Fixes #45682
Replaces #48533
Screenshot after the fix:
I don't like the way I fixed this tbh.
From reading the existing code, the bug should exist even for single-line conditions, but that's not the case.
Actually, the following existing test shows that:
roslyn/src/EditorFeatures/CSharpTest/Structure/BlockSyntaxStructureTests.cs
Lines 287 to 302 in cf55f3a
the start of the hint is at the "else" part.
There should be some modifications on the hint span somewhere, and that unknown place should be where the fix is included.