Skip to content

Commit baacd79

Browse files
committed
Format code blocks to multiple lines
1 parent d249d4e commit baacd79

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/CSharpOnTypeFormattingPass.cs

-10
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,6 @@ private static void CleanupSourceMappingStart(FormattingContext context, Range s
272272

273273
if (newLineCount == 0)
274274
{
275-
// If on type formatting is happening on a single line then we just clean up the start to one space
276-
// so @{ throw null; } will be formatted to @{ throw null; }
277-
// Ideally we'd put that across three lines, which is what normal formatting does, but since we
278-
// can't control the cursor, that doesn't end well.
279-
if (isOnType && sourceMappingRange.Start.Line == sourceMappingRange.End.Line)
280-
{
281-
changes.Add(new TextChange(spanToReplace, " "));
282-
return;
283-
}
284-
285275
newLineAdded = true;
286276
newLineCount = 1;
287277
}

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting/CodeDirectiveOnTypeFormattingTest.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,9 @@ await RunOnTypeFormattingTestAsync(
397397
",
398398
expected: @"
399399
<div></div>
400-
@{ Debugger.Launch(); }
400+
@{
401+
Debugger.Launch();
402+
}
401403
<div></div>
402404
");
403405
}
@@ -419,7 +421,9 @@ await RunOnTypeFormattingTestAsync(
419421
",
420422
expected: @"
421423
<div></div>
422-
@{ Debugger.Launch(); }
424+
@{
425+
Debugger.Launch();
426+
}
423427
<div></div>
424428
");
425429
}
@@ -441,7 +445,9 @@ await RunOnTypeFormattingTestAsync(
441445
",
442446
expected: @"
443447
<div>
444-
@{ Debugger.Launch(); }
448+
@{
449+
Debugger.Launch();
450+
}
445451
</div>
446452
");
447453
}

0 commit comments

Comments
 (0)