Typescript: Keep tabs option in VS 2015 is not preserved

Created on 12 Aug 2015  ·  46Comments  ·  Source: microsoft/TypeScript

When I select "Keep tabs" option in Visual Studio 2015 I get "Insert spaces" option selected on the next run of Visual Studio.

Visual Studio: 14.0.23107.0
TypeScript: 1.5.3.0

Bug External Visual Studio

Most helpful comment

Good news: we've found the cause of the problem and the fix will be in the next "micro update" (AKA Update 3.5), which should be released soon. In the meantime, as a workaround, you can edit HKCU\Software\Microsoft\VisualStudio\14.0\Profile\AutoSaveFile to be an invalid file path (such as "c:\/"). VS will complain about being unable to write the file whenever you exit, but you can ignore that. Thanks for all your help on this issue!

-Josh

All 46 comments

perhaps related to #4014

Same versions and result as NeuwirthD. Frustrating and creating a lot of trash diffs on source that was all 'keep tabs' previously. The CurrentSettings.vssettings file keeps getting overwritten by a InsertTabs: false value on VS close. Changing the option in the UI writes the correct value to the file at the time changes are saved.

Every member of our team experience the same problem. Any workarounds?

@ahmad-farid can you take a look

Any updates on this?

@paulvanbrenk can you take a look.

I don't reproduce this on VS 2015 + TS 1.6

Do you have multiple instances of VS open, maybe on multiple machines? Do you sync your settings (see the synchronized settings option)? Do you have other extensions installed?

Hadn't noticed this was just for Typescript... I'm seeing this issue with C#, whether I set the language setting directly or through "All languages". It appears to lose the setting when you close VS (or perhaps just opening a new instance is enough). Happens every time, and loses "keep tabs" and "smart tabs" setting. Vs2013 continues to work correctly.

The number of instances of VS doesn't matter, it happens even if I open only one instance of VS. I use VS on one machine. Yes, I synchronize settings. Yes, I have several other extensions installed.

@paulvanbrenk I can confirm, with Typescript 1.6.3.0 the original issue doesn't reproduce anymore.

After upgrading to TypeScript 1.6.3.0 I can still reproduce this issue.

@NeuwirthD which extensions do you have installed, does it reproduce when you disable all of them? Does it reproduce for other languages?

No extensions at all on my install. I am signed into msdn account though, so maybe sync related...

Can you please check whether it still repros while signed out? And can you please send me the files under %localappdata%\Microsoft\visualstudio\settingslogs? Thanks!

Yep signed out and same issue. Tried setting in "All languages" and just C#. Exited and re-opened VS, and C# reverted to "Insert spaces". I could send a video if it'll help.

Will you be able to send the setting logs I requested?

For me it only happens for TypeScript language.

any chance that #4014 is addressed too?

Thanks to @NeuwirthD we've identified the root cause of the problem. We'll be fixing it in a future release (I'm not sure which one yet), but as a workaround you can do this:

  1. Shut down all running instances of VS.
  2. Delete value “Insert Tabs” under HKCU\Software\Microsoft\Visualstudio\14.0\Text Editor.
  3. Find the .pkgdef file that sets the value DefaultToInsertSpaces for your language. For TypeScript, this is %programfiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\TypeScriptVisualStudio.pkgdef.
  4. In the .pkgdef file, change DefaultToInsertSpaces from 1 to 0.
  5. Run devenv /setup.

@JoshuaBStevens, I am using Visual Studio 2015 Community Edition Update 3 and I still see this with C#. Set the setting, exit and restart Visual Studio and it's back. Settings synchronization is also turned off... A grep of the Visual Studio common extensions folder does not make it immediately obvious which file I would edit to save myself from this space-ridden nightmare.

user@localhost:/mnt/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft$ grep -Ri "DefaultToInsertSpaces" .
./ReportingServices/ReportDesigner.PkgDef:"DefaultToInsertSpaces"=dword:00000000
./Roslyn/Language Services/VisualBasicPackageRegistration.pkgdef:"DefaultToInsertSpaces"=dword:00000001
./TypeScript/TypeScriptVisualStudio.pkgdef:"DefaultToInsertSpaces"=dword:00000001
./Web/ASPX/HTML_Editor_Reg.pkgdef:"DefaultToInsertSpaces"=dword:00000001
./Web/ASPX/HTML_Editor_Reg.pkgdef:"DefaultToInsertSpaces"=dword:00000001
./WebClient/Language Service/Microsoft.VisualStudio.JSLS.pkgdef:"DefaultToInsertSpaces"=dword:00000001
./WebClient/Language Service/Microsoft.VisualStudio.JSLS.pkgdef:"DefaultToInsertSpaces"=dword:00000001
Binary file ./XamlLanguageService/Microsoft.VisualStudio.DesignTools.XamlLanguageService.dll matches
user@localhost:/mnt/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft$

@mmaguigan, thanks for reaching out to me. We're aware of the issue but haven't found the root cause (or been able to reproduce it ourselves), so if you can help me by answering a few questions, I'd appreciate it.

  1. Have you changed the default “Automatically save my settings to this file” path in Tools -> Options -> Environment -> Import and Export Settings?
  2. After you set the option to "keep tabs", what is the value of "Insert Tabs" under HKCU\Software\Microsoft\VisualStudio\14.0\ApplicationPrivateSettings\TextEditor\CSharp?
  3. After restarting VS (when the option has reverted to "Insert spaces"), what is the value of that registry location?
  4. After you set the option to "keep tabs", what is the value of the element under the
  5. After restarting VS (when the option has reverted to "Insert spaces"), what is the value of that element in the file?

Thanks!
-Josh

I just experienced an activity that caused the 'keep tabs' to go back to 'insert spaces' for Visual Studio 2015, if this provides any insight to this very serious problem. I installed "ConfigurationTransform.vsix", and that immediately forced me back to spaces after I re-opened visual studio. And yes, it also sets the regedit value back to 0 from 1 as well.

@Architect-I, thanks for reporting that. Unfortunately, I can't reproduce it. Here is what I tried:

  1. Start VS (VS 2015 Update 3) and switch to "Keep tabs" under Text Editor / All Languages / Tabs.
  2. Restart VS and confirm that the setting is still "Keep tabs" for all languages.
  3. Download and install ConfigurationTransform.vsix from the VS Gallery website.
  4. Restart VS.

At that point, the setting was still "Keep tabs" for all languages. If your repro was different from this, can you tell me how so I can try the correct steps?

Thanks!
-Josh

Anyone having this problem on VS 2015 Update 3: please apply the DLLs in the attached zip archive using the patch.cmd script. This will add more details to %localappdata%\Microsoft\VisualStudio\SettingsLogs*.tsv and also create a new log file %localappdata%\VSProfilesLog.txt. If you could reply to this thread with the resulting logs after the problem occurs again, it would be very helpful.

Thanks!
-Josh
SettingsLogPatch.zip

I can't narrow down what activities cause the problem for me (practically hourly every day). The latest cause was simply opening one empty instance of visual studio 2015, seeing the setting still fine, then opening another empty instance of visual studio 2015 and then immediately seeing the setting ruined on both instances.

The 'maintain pin status if document is removed from well' is also randomly unselected.

@Architect-I, if you're running VS 2015 Update 3, please apply the patch I provided above and upload the files after the issue repros again. If you're running a different version, please just upload the %localappdata%\Microsoft\VisualStudio\SettingsLogs*.tsv files you already have.

Thanks,
-Josh

I am also experiencing this with VS2015 - no extensions installed (** excl typescript and node). I only have 1 instance open with Typescript, and it reverts seemingly at random. I have another instance doing C# work, and often have 4-5 instances running but have not experienced this issue with any language other than typescript. I'm running a fairly recent install of Windows 7 and Update 3 of VS2015

I don't feel comfortable running untrusted DLLs I'm afraid -- if you link to where they came from I can do that though.

@tastywheattasteslikechicken, I understand your reluctance to apply the patch. There is no link because we haven't shared them out publicly at all. They are Authenticode signed by Microsoft, if that helps. I'm an engineer on VS and I built them myself. Anyway, if you still don't want to install them, could you upload your %localappdata%\Microsoft\VisualStudio\SettingsLogs*.tsv files anyway? Thanks.

@JoshuaBStevens I feel a little silly now -- checked and yeah those files are signed.
I applied them using that patch tool and did the following (and a bunch more):

  1. Open Visual Studio. Confirm "Keep Tabs" option is already set (from previous launches)
  2. Open typescript project (.njsproj)
  3. Open 2nd instance of VS.
  4. 2nd instance has Keep tabs to false, first set to true
  5. Close all VS

...muck around trying to get it to happen...

  1. Open 1 VS, open .njsproj file. Is set to insert spaces. Set from Insert Spaces to Keep Tabs
  2. Open 2nd VS
  3. 1st instance has it set to spaces now.
  4. Close all VS

The log should start with the problem occurring without your patch, then show it occurring with your patch. Normally the 1st instance gets insert spaces, but this time only the second one got it.
SettingsLogPatch.zip

Thanks, @tastywheattasteslikechicken. It looks like the bad setting came from %userprofile%\documents\visual studio 2015\settings\CurrentSettings.vssettings, which was imported on startup (in step 2 of your repro) because VS detected that it had been updated. It's possible that the update came from the other VS instance, but the log doesn't indicate that. Could you try running Process Monitor to watch writes to that file and see if there is any other process besides devenv.exe touching it?

@JoshuaBStevens, I'll have a look, but would that change it in the original instance as well as the newly launched one? I'll have time to have a look on the weekend and will send you a summary as well as a filtered set of events for you to look at (just accesses to that file, with annotation on what action I was performing at the time)

@tastywheattasteslikechicken, if that file was changed by a different process, it would not automatically be reloaded in any already-running VS instance, only in the subsequently launched instance. However, after it was changed in the second instance, it would effectively be synced back to the first instance via the shared/roaming settings service. (Roamable settings are synced between running instances even if you aren't signed in.) So effectively it would result in both instances getting the "bad" setting value.

@tastywheattasteslikechicken, could you also set up Process Monitor to watch for registry operations under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\Profile? That may help pinpoint the root cause.

It looks like visual studio just resets tabs settings. I don't know when VS does it, but sometimes (very often) when i open VS2015 there is no radiobutton selected TextEditor->C#->Tabs (as like as i just have installed VS)

I think the problem is wider, than "tabs only". For me, basically all settings are randomly reset on VS2015 (with Update 3) restarts, including tabs, scroll bar map mode, etc. And not only for TS, but for the whole VS. It is EXTREMELY annoying, as it happens multiple times a day, and I have to go and set all those manually, as many of these affect how code cleanup in Resharper works.

There is seemingly no single cause for this - at least I do not see any clear reason.

I don't think it's visual studio on its own -- I never experienced this prior to installing typescript

I have the same issue both with VS 2015 U3 and SSMS 2016 which uses the VS Shell

@tastywheattasteslikechicken, I don't even use typescript. I notice this behavior with c# development, if I open another instance of VS, the tab settings revert to spaces. This behavior is exhibited on a clean installation of Windows.

Same, no typescript here. This problem has been happening for me since VS2015 release.

Good news: we've found the cause of the problem and the fix will be in the next "micro update" (AKA Update 3.5), which should be released soon. In the meantime, as a workaround, you can edit HKCU\Software\Microsoft\VisualStudio\14.0\Profile\AutoSaveFile to be an invalid file path (such as "c:\/"). VS will complain about being unable to write the file whenever you exit, but you can ignore that. Thanks for all your help on this issue!

-Josh

@JoshuaBStevens, I don't mean to fill this thread with meaningless posts like "first!", but perhaps it is best if someone says it at least once, so the sentiment is there... That said, I'm going to leave this here:

YAY!!!!!!!!! 🍰 🎈 😄

I'll point a link to the Micro Update when it ships. @JoshuaBStevens can you help me remind to do that.

This is great news that you found a solution to this problem.

Of course, the next problem is that the 'maintain pin status if document is removed from well' is also randomly unselected. And unfortunately, the temporary workaround fix for the 'keep tabs' listed above (to set the registry to an invalid path) does not solve the pin status problem.

@Architect-I, if you're running Update 3, could you try the patch I posted above and then upload the settings logs when it happens again?

Thanks,
-Josh

Was the fix for this included in the latest micro-update (https://msdn.microsoft.com/en-us/library/mt752379.aspx)? The release notes mention _Text Editor settings now persist as expected. In earlier updates to Visual Studio 2015, text editor settings frequently reverted automatically_, which I assume is this.

@link1305, yep, it should be in there. Let me know if you encounter any other settings issues.

-Josh

Was this page helpful?
0 / 5 - 0 ratings