VS replaces tabs by spaces

This forum is meant for anything you would like to share with other visitors
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

VS replaces tabs by spaces

Post by Chris »

Thanks Karl!!!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

VS replaces tabs by spaces

Post by ic2 »

I've also posted this using VS Help/Send Feedback, Report a problem. It can then be seen in:

https://developercommunity.visualstudio ... paces.html

The general way Visual Studio staff handles these issues is that hardly ever an issue is solved; in the best case the issue is closed to be a duplicate of an issue which is not solved either as they did here. They refer to https://github.com/dotnet/roslyn/issues/24031 where it is posted for the VS 2017 version and still not solved in 2019.

However, Karl showed it works for him and it also works for Kees with whom I checked all my settings. I still have no idea what causes the difference.

If they had capable people working at Microsoft (like the X# team works) there should be someone who could tell: we checked in the code what
could cause tabs to be replaced with spaces, if you change this and this it should be solved.

Unfortunately they don't have capable people working at Microsoft. So I keep using VS with a problem which could probably be solved but it is unknown how. As if working with Visual Studio isn't already punishment enough without the tabs->spaces replacement :evil:

Dick
User avatar
Kees Bouw
Posts: 119
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

VS replaces tabs by spaces

Post by Kees Bouw »

Hi all,

I have found that the Visual Studio (2019 with all updates installed) designer changes tabs to spaces. Each tab is replaced by one space. If I open for example a Winforms application "test" by double clicking on "test.prg" the designer is opened. Then I choose View->Code and verify that there are tabs. Then I choose View->Designer, I change something (just moving a button to a new position is enough) and save. When I go back to View->Code all the tabs have been replaced by spaces. Selecting everything and choosing Edit->Advanced->Tabify Selected Lines corrects it but only at the start of the lines. Tabs elsewhere in the line are not corrected. This is not the only way the designer can screw up your code. I have had code completely disappear, or code duplicate just by going to the designer and back. It is a complete mystery to me how such a giant company like Microsoft with practically unlimited financial resources cannot even get these simple things right.

Kees.
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

VS replaces tabs by spaces

Post by robert »

Kees,
How much I would like to blame Microsoft for this, I must admit that the code generation here is not done by Microsoft but but an X# component.
I will see why this component does not use the correct settings for the code generation and fix this.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

VS replaces tabs by spaces

Post by Chris »

Kees and Dick, just to let you know, I remember you reported some time ago this problem with the editor changing tabs to spaces, but we could not reproduce it. Looks like what was missing when trying to reproduce it, was that info that this change happens in a file that represents a form, after making a change in the designer.

Now the problem is easily reproducable and actually it looks like exactly like an issue I had also reported myself last month (https://github.com/X-Sharp/XSharpPublic/issues/438), which I had thought only had to do with indentation. But apparently it's a general tabs/spaces problem where the form designer is involved. So thanks for the new info on this which was really helpful!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

VS replaces tabs by spaces

Post by ic2 »

Hello Chris,

My "spaces replacement" problem is actually different than that of Kees. It also happens in C#. I've made a bit of progress. If I copy a method containing tabs (for the comments) and paste it, all the tabs are replaced with spaces. This also happens when VS reformats, e.g. when I add a closing } to a C# block.

But, what I found out recently, if I directly press Ctrl Z once, the tabs are back, without losing my pasted code or closing }.

It seems there's an unwanted step in VS doing that, but not for everyone and I have no idea why. I've reported that in the discussion on https://developercommunity.visualstudio ... tab/847853 (expand Show 15 comments at the bottom). There's actually a product manager at Microsoft in charge of the Adaptive White Space feature in Visual Studio, Dante Gagne, and as this feature is so totally not working one wonders how any improvements can ever take place when this manager himself writes about this crippled functionality the reply below. Not sure if this has anything to do with what you describe or I see happening, however. It does show once more that I am certainly not the only one complaining about VS ("tons of feedback")

Dick

Hey Folks. I’m the PM here at Microsoft in charge of the Adaptive White Space feature in Visual Studio. Basically, we’ve gotten tons of feedback from folks who copy/paste code into a variety of codebases and get into trouble when their settings conflict with the standards of the document. I can’t begin to count how many people have said “Come on, the document uses nothing but tabs, why can’t Visual Studio figure that out and use tabs?”

Here are a few comments:

First, PLEASE feel free to continue to send more feedback. We don’t currently have an option to disable adaptive white space, but if folks feel that’s important, we can add it.
Second, if you look at the bottom right of the editor window, you’ll see that we’ve brought Line, Character, Whitespace and Line Endings closer to the document. These will tell you if Visual Studio thinks the document is a document with spaces or tabs and that’s what it will use for that document. You can also click that indicator and tell it which one you want to use. It will update all of the whitespace in the document to whichever you prefer and use that as a standard from then on.
Third, if you use .editorconfig in your code repo, we will ALWAYS honor those settings. It’s not a requirement to use .editorconfig, but anyone who is particular interested in maintaining a coding style should know that our of the VS guiding principles is to never believe we’re “smart enough” to override .editorconfig.

User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

VS replaces tabs by spaces

Post by Chris »

Wow, I think I'd better not comment on that...
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

VS replaces tabs by spaces

Post by ic2 »

I have one more comment. The "Microsoft manager Adaptive white spaces" Dante Gagne didnt' react anymore (too busy with white spaces I am afraid while my problem is tab related, I definitely have to find Microsofts "Senior Manager Visual Studio Unwanted Spaces" somewhere I think).

So I posted a new issue on the forum, more precisely the Mac forum because my Report Issues option is missing and even when I manually edit the menu to put it back somewhere, it shows but greyed out, and yes, I am logged in. Even after a full menu & settings reset to default. One of the many great surprises of VS. Here it is:

https://developercommunity2.visualstudi ... al/1518561

To my surprise a MSFT, Andew Hall, reacted by describing + adding a screenshot of just what goes wrong.

That sounds like progress, although he didn't write how to prevent it and he hasn't reacted since this weekend.

Andrew is Senior Program Manager on the Visual Studio Debugger team. He probably isn't even acquainted with the Microsoft Senior or Junior Manager Unwanted Spaces, or it still looking for that manager to ask why on earth this happens on, apparently, his system as well.

Dick
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

VS replaces tabs by spaces

Post by Chris »

Hi Dick,

Maybe right now the problem is already fixed by the Senior Developer of the Adaptive White Space feature in Visual Studio, but the Project Manager of the Adaptive White Space feature in Visual Studio has assigned it to the Senior and Junior members of the Principal Testing team for the Adaptive White Space feature in Visual Studio who haven't confirmed the fix yet, or maybe are still waiting for the Project Manager of the Help file contents of the Adaptive White Space feature in Visual Studio to assign it to one of the members of the team so that it is probably documented how this feature works.

Sorry, I know I said I shouldn't comment, but I could not resist anymore :)
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

VS replaces tabs by spaces

Post by ic2 »

Hello Chris,

This is very funny to read. But I am afraid that's how it works at Microsoft (or other large software companies in the world).

Dick
Post Reply