You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backport of #11908 and #11911 to release/dev17.14
Fixes
[developercommunity.visualstudio.com/t/Format-Document-in-Razor-pages-no-longer/10903159](https://developercommunity.visualstudio.com/t/Format-Document-in-Razor-pages-no-longer/10903159)
Fixes
[devdiv.visualstudio.com/DevDiv/_workitems/edit/2471065](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2471065)
/cc @davidwengier
## Customer Impact
## Regression
- [ ] Yes
- [ ] No
[If yes, specify when the regression was introduced. Provide the PR or
commit if known.]
## Testing
[How was the fix verified? How was the issue missed previously? What
tests were added?]
## Risk
[High/Medium/Low. Justify the indication by mentioning how risks were
measured and addressed.]
Copy file name to clipboardExpand all lines: src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/New/CSharpFormattingPass.CSharpDocumentGenerator.cs
Copy file name to clipboardExpand all lines: src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/New/CSharpFormattingPass.LineInfo.cs
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ internal partial class CSharpFormattingPass
13
13
/// <param name="CheckForNewLines">Whether the origin document text could have overflowed to multiple lines in the formatted document</param>
14
14
/// <param name="SkipPreviousLine">Whether to skip the previous line in the formatted document, since it doesn't represent anything in the origin document</param>
15
15
/// <param name="SkipNextLine">Whether to skip the next line in the formatted document, since it doesn't represent anything in the origin document</param>
16
+
/// <param name="SkipNextLineIfBrace">Whether to skip the next line in the formatted document, like <see cref="SkipNextLine" />, but only skips if the next line is a brace</param>
16
17
/// <param name="HtmlIndentLevel">The indent level that the Html formatter applied to this line</param>
17
18
/// <param name="OriginOffset">How many characters after the first non-whitespace character of the origin line should be skipped before applying formatting</param>
18
19
/// <param name="FormattedLength">How many characters of the origin line the formatted line represents</param>
@@ -25,6 +26,7 @@ private readonly record struct LineInfo(
// Sanity check: Because we're looking ahead through lines until the original line content is fully matches, we could loop forever if there is a bug somewhere
// If there are more non-whitespace chars in the original line, then its something like "if (true) {" to "if (true)", so keep inserting formatted lines until we're past the brace.
_logger.LogError($"Ran out of formatted lines while trying to process formatted changes after {iOriginal} lines. Abandoning further formatting to not corrupt the source file, please report this issue.");
// Otherwise, there are more whitespace chars in the formatted line, so "if (true)" to "if (true) {", so we need to remove the original lines until we're past the brace.
125
+
varoldEnd=originalLine.End;
126
+
iOriginal++;
127
+
if(iOriginal>=changedText.Lines.Count)
128
+
{
129
+
_logger.LogError("Ran out of lines while trying to process formatted changes. Abandoning further formatting to not corrupt the source file, please report this issue.");
0 commit comments