AddAnyFile icon indicating copy to clipboard operation
AddAnyFile copied to clipboard

Files created through "Add New File" do not respect tab preferences

Open luluco250 opened this issue 5 years ago • 2 comments

Installed product versions

  • Visual Studio: 2019 Enterprise
  • This extension: 3.5.138

Description

I have Visual Studio configured to "Keep tabs" for C#, however the extension always creates files with spaces instead (as opposed to the native "Add new item" tool).

It also ignores indent size if spaces are used, for example, with 2 spaces indentation the extension will still create files with 4 spaces.

It'd be preferable that it respected tab settings.

This issue is partly equal to #24 but that doesn't mention that the extension will also ignore "Indent size" for spaces.

Steps to recreate

  1. Open Visual Studio, with a solution/project loaded.
  2. Configure the use of tabs over spaces in the settings through "Tools > Options... > Text Editor > C# > Tabs > Tab > Keep tabs".
  3. Create a .cs file with the extension.
  4. Verify that it used spaces instead of tabs.
  5. Reconfigure the tab settings to "Insert spaces" and set the "Indent size" to 2.
  6. Repeat step 3.
  7. Verify that it used 4 spaces instead of 2 spaces.

Current behavior

C# files created through the extension always use 4 spaces indentation, regardless of tab settings.

Expected behavior

C# files created through the extension should follow tab settings, using tab indentation if "Keep tabs" is used and/or using exactly the N amount of spaces configured with "Indent size" otherwise.

luluco250 avatar Feb 19 '20 11:02 luluco250

As a workaround, you can edit the used template files.

After installing the extension, they are located here: LocalDisk:\Users\UserName\AppData\Local\Microsoft\VisualStudio\16.0\Extensions\RandomFolderNameForAddNewFileExtension\Templates

anreton avatar Feb 19 '20 17:02 anreton

As a workaround, you can edit the used template files.

After installing the extension, they are located here: LocalDisk:\Users\UserName\AppData\Local\Microsoft\VisualStudio\16.0\Extensions\RandomFolderNameForAddNewFileExtension\Templates

Ah, that's good enough for me, thanks.

luluco250 avatar Feb 19 '20 21:02 luluco250