Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

tab_width should fall back to indent_size #22601

Open
sharwell opened this issue Oct 9, 2017 · 5 comments
Open

tab_width should fall back to indent_size #22601

sharwell opened this issue Oct 9, 2017 · 5 comments
Labels
Area-IDE Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-Formatter Code formatter and/or smart indent
Projects
Milestone

Comments

@sharwell
Copy link
Member

sharwell commented Oct 9, 2017

Version Used: 15.1

馃敆 Originally posted on developer community by Clinton Ingram (@saucecontrol?).

Steps to Reproduce:

Use the following .editorconfig file:

[*.cs]
indent_style = tab
indent_size = 16

Expected Behavior:

The editor formats code with a single hard-tab for indentation, which is displayed in the editor with a width of 16 characters. According to the EditorConfig format:

tab_width: a whole number defining the number of columns used to represent a tab character. This defaults to the value of indent_size and doesn't usually need to be specified.

Actual Behavior:

The editor formats code with multiple hard tabs for indentation.

Impacted code:

// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
public static PerLanguageOption<int> TabSize { get; } =
new PerLanguageOption<int>(nameof(FormattingOptions), nameof(TabSize), defaultValue: 4,
storageLocations: EditorConfigStorageLocation.ForInt32Option("tab_width"));

@sharwell sharwell added Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Oct 9, 2017
@sharwell
Copy link
Member Author

sharwell commented Oct 9, 2017

馃摑 We also have an internal bug tracking editor-related functionality impacted by this interpretation of the EditorConfig file.

@sharwell sharwell added the Developer Community The issue was originally reported on https://developercommunity.visualstudio.com label Oct 9, 2017
@jinujoseph jinujoseph added this to the Unknown milestone Oct 20, 2017
@MhdTlb
Copy link

MhdTlb commented Nov 9, 2017

Can I work on this?

@sharwell
Copy link
Member Author

sharwell commented Nov 9, 2017

@MhdTlb Yes. Do keep in mind that I'm not certain this is an issue that may or may not have an easy solution. If you get stuck, let us know and we'll try to track down the right person to unblock you. 馃槃

@sharwell sharwell added this to InQueue in Small Fixes via automation Jan 15, 2019
@sharwell sharwell added the IDE-Formatter Code formatter and/or smart indent label Mar 18, 2019
@Gargaj
Copy link

Gargaj commented Jun 22, 2019

This has a weird effect on the auto-formatter (Format Selection or Format Document) in that if there's a difference between tab_width and indent_size, it will use the incorrect amount of indentations.

@Eilon
Copy link
Member

Eilon commented Aug 25, 2020

Got here from dotnet/format#574 because this affects running dotnet format where you get a weird mix of tabs and spaces in the same document. Fortunately, the workaround of setting tab_width to the same value as indent_size works.

Eilon added a commit to FritzAndFriends/BlazorWebFormsComponents that referenced this issue Aug 25, 2020
Used 'dotnet format' command with a tweaked .editorConfig file to format all files.
- A small change was made to .editorConfig to work around dotnet/roslyn#22601
- The BeforeWebForms project wasn't updated because 'dotnet format' can't process the legacy project
- The main changes are tab consistency and namespace cleanup, but a few other minor changes were made
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-Formatter Code formatter and/or smart indent
Projects
Small Fixes
  
InQueue
Development

No branches or pull requests

5 participants