Skip to content

Razor inserts too many spaces when formatting (LF instead CRLF in file) #7912

@arduinka55055

Description

@arduinka55055

Is this a Bug or Feature request?:

Bug

Description of the problem:

After file format the amount of spaces grows
looks like it hates @{} structure:

Steps to reproduce

изображение

Now formatting this:
изображение
The result:
изображение
изображение
изображение

can see exponential growth (0 spaces, then 1, 3, 7, 15, ...)

Razor issue logs(as vscode adviced me):

Logs

OmniSharp

To find the OmniSharp log, open VS Code's "Output" pane, then in the dropdown choose "OmniSharp Log".

Starting OmniSharp server at 13.11.2022, 22:09:26
    Target: c:\Users\Денис\Desktop\MvcProxy

OmniSharp server started with .NET 6.0.403
.
    Path: c:\Users\Денис\.vscode\extensions\ms-dotnettools.csharp-1.25.2-win32-x64\.omnisharp\1.39.2-net6.0\OmniSharp.dll
    PID: 21164

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 10.0.22621.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
        Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: .NET Core SDK 6.0.403 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.403\"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: .NET Core SDK 6.0.403 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.403\"
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\Денис\Desktop\MvcProxy'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\Users\Денис\Desktop\MvcProxy'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Денис\Desktop\MvcProxy\MvcProxy.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\Денис\Desktop\MvcProxy'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\Денис\Desktop\MvcProxy' on host 23772.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\Денис\Desktop\MvcProxy\MvcProxy.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Users\Денис\Desktop\MvcProxy\MvcProxy.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\Денис\Desktop\MvcProxy\MvcProxy.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: MvcProxy

Razor

Expand

[Client - 22:16:30] -- Starting Issue Data Collection-- 
[Client - 22:16:32] Updating the C# document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (169)
[Client - 22:16:32] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'csharpChanged'
[Client - 22:16:32] Updating the HTML document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (169)
[Client - 22:16:32] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'htmlChanged'
[Client - 22:16:33] Updating the C# document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (170)
[Client - 22:16:33] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'csharpChanged'
[Client - 22:16:33] Updating the HTML document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (170)
[Client - 22:16:33] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'htmlChanged'
[Client - 22:16:33] Updating the C# document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (171)
[Client - 22:16:33] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'csharpChanged'
[Client - 22:16:33] Updating the HTML document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (171)
[Client - 22:16:33] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'htmlChanged'
[Client - 22:16:34] Updating the C# document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (172)
[Client - 22:16:34] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'csharpChanged'
[Client - 22:16:34] Updating the HTML document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (172)
[Client - 22:16:34] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'htmlChanged'
[Client - 22:16:34] Updating the C# document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (173)
[Client - 22:16:34] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'csharpChanged'
[Client - 22:16:34] Updating the HTML document for Razor file 'c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml' (173)
[Client - 22:16:34] Notifying document 'c:\Users\anonymous\Desktop\MvcProxy\Views\Auth\Index.cshtml' changed 'htmlChanged'
[Client - 22:16:35] -- Stopping Issue Data Collection-- 

Workspace information

Razor document:

Expand

<h1>It really hates this:</h1>
@{































    var foo = "bar";
}

Projected CSharp document:

Expand

////////////////////// Projected CSharp as seen by extension ///////////////////////
// <auto-generated/>
#pragma warning disable 1591
namespace AspNetCore
{
    #line hidden
    using TModel = global::System.Object;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.Rendering;
    using Microsoft.AspNetCore.Mvc.ViewFeatures;
#nullable restore
#line 1 "c:/Users/anonymous/Desktop/MvcProxy/Views/_ViewImports.cshtml"
using MvcProxy;

#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "c:/Users/anonymous/Desktop/MvcProxy/Views/_ViewImports.cshtml"
using MvcProxy.Models;

#line default
#line hidden
#nullable disable
    public class Views_Auth_Index : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
    {
        #pragma warning disable 219
        private void __RazorDirectiveTokenHelpers__() {
        }
        #pragma warning restore 219
        #pragma warning disable 0414
        private static System.Object __o = null;
        #pragma warning restore 0414
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#nullable restore
#line 2 "c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml"
  































    var foo = "bar";

#line default
#line hidden
#nullable disable
        }
        #pragma warning restore 1998
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
    }
}
#pragma warning restore 1591



////////////////////// Projected CSharp as seen by VSCode ///////////////////////
// <auto-generated/>
#pragma warning disable 1591
namespace AspNetCore
{
    #line hidden
    using TModel = global::System.Object;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.Rendering;
    using Microsoft.AspNetCore.Mvc.ViewFeatures;
#nullable restore
#line 1 "c:/Users/anonymous/Desktop/MvcProxy/Views/_ViewImports.cshtml"
using MvcProxy;

#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "c:/Users/anonymous/Desktop/MvcProxy/Views/_ViewImports.cshtml"
using MvcProxy.Models;

#line default
#line hidden
#nullable disable
    public class Views_Auth_Index : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
    {
        #pragma warning disable 219
        private void __RazorDirectiveTokenHelpers__() {
        }
        #pragma warning restore 219
        #pragma warning disable 0414
        private static System.Object __o = null;
        #pragma warning restore 0414
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#nullable restore
#line 2 "c:/Users/anonymous/Desktop/MvcProxy/Views/Auth/Index.cshtml"
  































    var foo = "bar";

#line default
#line hidden
#nullable disable
        }
        #pragma warning restore 1998
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
    }
}
#pragma warning restore 1591

// 86

Projected Html document:

Expand

////////////////////// Projected Html as seen by extension ///////////////////////
<h1>It really hates this:</h1>
~~































    ~~~ ~~~ ~ ~~~~~~
~


////////////////////// Projected Html as seen by VSCode ///////////////////////
<h1>It really hates this:</h1>
~~































    ~~~ ~~~ ~ ~~~~~~
~
// 172

Machine information

VSCode version: 1.73.1
Razor.VSCode version: 1.25.2

dotnet --info

Expand

����� SDK ��� .NET:
 Version:   6.0.403
 Commit:    2bc18bf292

�।� �믮������:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.403\

global.json file:
  Not found

Host:
  Version:      6.0.11
  Architecture: x64
  Commit:       943474ca16

.NET SDKs installed:
  6.0.403 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

Extensions

Expand

Extension Author Version
asm-code-lens maziac 1.10.2
autodocstring njpwerner 0.6.1
autoimport steoates 1.5.4
better-cpp-syntax jeff-hykin 1.16.3
bullshit Wscats 0.0.5
cmake twxs 0.0.17
cmake-tools ms-vscode 1.12.27
copilot GitHub 1.58.7236
cpptools ms-vscode 1.13.3
cpptools-extension-pack ms-vscode 1.3.0
cpptools-themes ms-vscode 2.0.0
csharp ms-dotnettools 1.25.2
discord-vscode icrawl 5.8.0
doxdocgen cschlosser 1.4.0
es6-string-html Tobermory 2.12.0
esp-idf-extension espressif 1.5.1
gitlens eamodio 13.0.4
hexeditor ms-vscode 1.9.9
html-css-class-completion Zignd 1.20.0
intellicode-api-usage-examples VisualStudioExptTeam 0.2.6
isort ms-python 2022.6.0
java redhat 1.12.0
jinja wholroyd 0.0.8
jshint dbaeumer 0.11.0
jupyter ms-toolsai 2022.9.1202862440
jupyter-keymap ms-toolsai 1.0.0
jupyter-renderers ms-toolsai 1.0.12
live-server ms-vscode 0.4.3
luna-paint Tyriar 0.16.0
MagicPython magicstack 1.1.0
makefile-tools ms-vscode 0.6.0
material-icon-theme PKief 4.22.0
omnipascal Wosi 0.19.0
pascal alefragnani 9.5.1
platformio-ide platformio 2.5.5
python ms-python 2022.18.2
python-environment-manager donjayamanne 1.0.4
python-extension-pack donjayamanne 1.7.0
qtvsctools tonka3000 0.11.0
reddit-memes sachinsinghroxx 0.3.0
remote-containers ms-vscode-remote 0.262.3
remote-explorer ms-vscode 0.0.2
remote-ssh ms-vscode-remote 0.92.0
remote-ssh-edit ms-vscode-remote 0.84.0
remote-wsl ms-vscode-remote 0.72.0
shader slevesque 1.1.5
shadered dfranx 0.0.5
stackoverflow-search Alexey-Strakh 1.2.0
vetur octref 0.36.1
vsc-python-indent KevinRose 1.18.0
vscode-3dviewer slevesque 0.2.2
vscode-css-peek pranaygp 4.2.0
vscode-django batisteo 1.10.0
vscode-docker ms-azuretools 1.22.2
vscode-eslint dbaeumer 2.2.6
vscode-firefox-debug firefox-devtools 2.9.8
vscode-glsllint dtoplak 1.8.0
vscode-gradle vscjava 3.12.5
vscode-html-css ecmel 1.13.1
vscode-java-debug vscjava 0.46.0
vscode-java-dependency vscjava 0.21.1
vscode-java-pack vscjava 0.25.6
vscode-java-test vscjava 0.37.1
vscode-JS-CSS-HTML-formatter lonefy 0.2.3
vscode-jupyter-cell-tags ms-toolsai 0.1.6
vscode-jupyter-slideshow ms-toolsai 0.1.5
vscode-maven vscjava 0.39.2
vscode-mysql-client2 cweijan 5.9.1
vscode-nbt Misodee 0.7.3
vscode-office cweijan 2.9.0
vscode-pylance ms-python 2022.11.20
vscode-sqlite alexcvzz 0.14.1
vscode-todo-highlight wayou 1.0.5
vscode-typescript-next ms-vscode 5.0.20221112
vscodeintellicode VisualStudioExptTeam 1.2.29
vsliveshare ms-vsliveshare 1.0.5762
x8664assembly fredhappyface 0.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions