dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 654 forks source link

.editorconfig not working for tab options #5616

Open mdsitton opened 1 year ago

mdsitton commented 1 year ago

Issue Description

So i got a new laptop yesterday and set up vscode with the most common extensions i use for C# development. I'm using vscode for unity development for context.

this is the editorconfig file being used:

is_global = true

[*.cs]
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

I've tried using "omnisharp.path": "latest", and blank with the same behavior

Here is my settings.json contents and i don't have anything in the workspace configured

{
    "workbench.colorTheme": "Laetus Blue",
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "omnisharp.useModernNet": true,
    "omnisharp.path": "latest",
    "omnisharp.enableDecompilationSupport": true,
    "omnisharp.enableAsyncCompletion": true,
    "omnisharp.enableRoslynAnalyzers": true,
    "omnisharp.enableEditorConfigSupport": true,
    "csharp.referencesCodeLens.enabled": false,
}

Steps to Reproduce

use .editorconfig in root project directory, with formatting options. Extension does not pick these settings up causing format on save to use the incorrect settings.

Expected Behavior

It should pull settings from the .editorconfig

Actual Behavior

It doesn't take the settings from the .editorconfig

Logs

OmniSharp log

Starting OmniSharp server at 3/9/2023, 8:20:01 PM Target: c:\Users\matth\development\test-project\test-project.sln OmniSharp server started with .NET 7.0.201 . Path: c:\Users\matth\.vscode\extensions\ms-dotnettools.csharp-1.25.4-win32-x64\.omnisharp\1.39.4-net6.0\OmniSharp.dll PID: 22240 [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 7.0.201 17.5.0 - "C:\Program Files\dotnet\sdk\7.0.201\" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: .NET Core SDK 7.0.201 17.5.0 - "C:\Program Files\dotnet\sdk\7.0.201\" [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'c:\Users\matth\development\test-project'. [info]: OmniSharp.Cake.CakeProjectSystem Did not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem Detecting projects in 'c:\Users\matth\development\test-project\test-project.sln'. [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\matth\development\test-project\Assembly-CSharp.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\matth\development\test-project\Assembly-CSharp-Editor.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'c:\Users\matth\development\test-project'. [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\matth\development\test-project' on host 3980. [info]: OmniSharp.MSBuild.ProjectManager Loading project: c:\Users\matth\development\test-project\Assembly-CSharp.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\matth\development\test-project\Assembly-CSharp.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\matth\development\test-project\Assembly-CSharp.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: c:\Users\matth\development\test-project\Assembly-CSharp-Editor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\matth\development\test-project\Assembly-CSharp-Editor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\matth\development\test-project\Assembly-CSharp-Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Update project: Assembly-CSharp [info]: OmniSharp.MSBuild.ProjectManager Update project: Assembly-CSharp-Editor [info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers Solution initialized -> queue all documents for code analysis. Initial document count: 188.

C# log

empty

Environment information

VSCode version: 1.76.1 C# Extension: 1.25.4

Dotnet Information .NET SDK: Version: 7.0.201 Commit: 68f2d7e7a3 Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.201\ Host: Version: 7.0.3 Architecture: x64 Commit: 0a2bda10e8 .NET SDKs installed: 7.0.201 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |ascii-unicode-escape|yaruson|0.1.0| |code-spell-checker|streetsidesoftware|2.19.0| |csharp|ms-dotnettools|1.25.4| |csharpextensions|kreativ-software|1.7.3| |gitlens|eamodio|13.3.2| |hexeditor|ms-vscode|1.9.11| |laetus|10F|0.0.9| |markdown-all-in-one|yzhang|3.5.0| |msbuild-project-tools|tintoy|0.4.9| |unity-debug|deitry|3.0.11| |vscode-unitymeta|PTD|0.0.7|;
josh-hemphill commented 1 year ago

I'm having the same issue. Looking at other issues, #5485 seems to be related if not duplicate.

mdsitton commented 1 year ago

I've also tested with just a standard fresh .net project that isn't unity and i'm seeing the same behavior. But i do see looking at my editorconfig, it did have an error.

I should have been using root = true not is_global = true. No idea where this came from but changing that resolves the issue for me.

There should be better errors when this occurs!

justinmchase commented 1 week ago

I have root = true and still have the issue. Whenever I create a new file it defaults to spaces not tabs.