-
Notifications
You must be signed in to change notification settings - Fork 513
Code formatting doesn't respect user's tabs-vs-spaces preference in "editor.insertSpaces" #530
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hmmm, interesting, I'll investigate. |
The formatter uses only spaces for indentation. We will eventually have the options of using tabs but I am not sure on the timeline for adding it. |
This means that our code is all being changed from tabs to spaces whenever we edit it, or to a mixture of tabs/spaces, if we use the formatter at all. Whereabouts is the codebase for the formatter? I'd be up for taking a stab at this myself if nobody else is picking it up. |
@andrewducker Allowing vscode to use tabs instead of spaces is definitely something we want to do soon. However, if you want to take a shot at implementing it, you will have to modify the following PSScriptAnalyzer rules.
We don't have unified way of dealing with tabs/spaces as of yet. You will have to go to each rule and duplicate the tabs/spaces logic. It would however be more preferable to have a unified way of handling tabs/spaces. Not having gotten around to putting such a unified way is the main reason, code formatter is lacking in this choice between tabs and spaces. |
This is effecting commits to GitHub using VS Code because every file I modify, with just one line, EVERY other line has the tabs converted to spaces. I have to manually issue the convert command to put them back. Not cool man! |
Interesting note, just updated VS Code Insider Edition and this does not seem to be an issue for me now. |
Hmmm, not sure why the Insider version would have improved this, but I'll keep an eye out for that! |
Ok, so installed 1.1.0 of PS extension and reloaded window...and above still exist. |
@wsmelton Is your The code formatter indents lines that have language constructs on them. Therefore, for some lines leading tabs get converted to spaces while for others they don't. |
@kapilmb it is set to false, default in user settings. That setting annoyed me after trying it so I never use it anymore. I do not explicitly set it to false in my settings.json file though, it just picks up the default. |
If What things about |
@kapilmb it is strictly personal opinion/preference. If I am typing out code, whether according to my format rules/settings or not, having it change whenever I hit enter just takes my focus off of where my cursor was/is. So strictly a preference for me. I mean maybe if it paused to format the block of text with a double-enter before actually formatting...I might turn it back on. Consider if you are typing out a script block in PowerShell and not worrying about formatting at the time, just getting it typed out. On average most folks will put two lines between logical sections of code, so if I have an if/else block after I type the end of the else block I will hit enter twice. At that time, or if this could be controlled in some manner as to when it would format as you type? |
System Details
$PSVersionTable
:Issue Description
I am experiencing a problem with code formatting.
When the "editor.insertspaces" option is set to false then I would expect the "format selection" option to use tabs for formatting the code. Instead it still used spaces.
The text was updated successfully, but these errors were encountered: