-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Describe the Issue
In some cases when saving (or anything that triggers formatting, I guess) a *.cshtml file in VS Code, blank lines are being added in some places with each save.
The user might not even notice that their file is growing. In my case, a fragment near the bottom of the page got blown so much that in a week or so the file grew by dozens of thousands of rows.
Appears to be a bug in the formatter that perhaps does not properly work with line endings.
Steps To Reproduce
VS Code on Windows working on code base with Unix line endings (LF).
The issue was not observed in Linux or in Windows when the file has Windows line endings {CRLF).
I have this near the end of one of my Razor pages:
@if (Model.IsActive)
{
<button type="submit" class="btn btn-primary" asp-page-handler="Inactivate">Inactivate</button>
}
else
{
<button type="submit" class="btn btn-primary" asp-page-handler="Activate">Activate</button>
<button type="submit" class="btn btn-primary" asp-page-handler="Save">Save</button>
}
</form>After one save, it looks like this
@if (Model.IsActive)
{
<button type="submit" class="btn btn-primary" asp-page-handler="Inactivate">Inactivate</button>
}
else
{
<button type="submit" class="btn btn-primary" asp-page-handler="Activate">Activate</button>
<button type="submit" class="btn btn-primary" asp-page-handler="Save">Save</button>
}
</form>After two saves:
@if (Model.IsActive)
{
<button type="submit" class="btn btn-primary" asp-page-handler="Inactivate">Inactivate</button>
}
else
{
<button type="submit" class="btn btn-primary" asp-page-handler="Activate">Activate</button>
<button type="submit" class="btn btn-primary" asp-page-handler="Save">Save</button>
}
</form>
and so on
Expected Behavior
Blank lines should not be added. The formatter should work correctly with either LF or CRLF files regardless of the OS VS Code is being used on.
Environment Information
Windows 11