Vscode: VSCode not to associate itself with any file type unless the user chooses so during installation

Created on 3 Jul 2016  路  20Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.2.1
  • OS Version: win10 x64

Steps to Reproduce:

  1. Install VSCode
  2. Open Control Panel > Control Panel Home > Default Programs > Assosiate a file type or protocol with a specific program:
    you'll notice that a hundred file types (in fact 101 !) are now associated with VSCode (screenshot 1).
    There was no such option to opt in during the installation (screenshot 2)
    neither there's a way to remove the file associations inside the program preferences.
    The only way remove the file associations is to uninstall VSCode altogether.

For reference, all other editors that I have installed: Sublime Text, Atom, Notepad++, gVim, UltraEdit
don't associate themselves with any file type.


So, my suggestion:
VSCode not to associate itself with any file extension unless the user chooses so during installation.
Even better, to be able to configure file type associations with VSCode (enable/disable each one) , inside the program's preferences.

bug install-update verified windows

Most helpful comment

How do I undo VSCode's damage on my Mac?

All 20 comments

I think there's already a checkbox on the installer for this. It's checked by default though, it should probably be opt-in.

No, there's no such checkbox. Please check screenshot 2 from my 1st post, and the attached video capture of the install procedure: Video_2016-07-03_235157.zip.

My belief is that Code doesn't associate itself automatically, but simply registers as a possible editor for such files. Will investigate this in July, since many people complain.

No, that's not the case.
Installer doesn't just add Code as an extra entry in windows explorer's rightclick|Open with menu for these file extensions:
2016-07-04_183804

I created various empty files with random extensions from my screenshot 1
and all are associated with Code :
2016-07-04_184313
In other words, doubleclicking any of these files, opens them in Code.

Yes, but did you have any other application that was able to open those files before you installed Code? It makes sense that Windows picked Code to be the default if Code is the only one.

_(sorry, accidentally closed the issue)_

I noticed two cases:

  • The .js files would open with Microsoft Windows Based Script Host (a windows component, it's by default).
    After installing Code they become assosiated with Code.
  • On the other hand, .sh files would open with Git for Windows.
    After installing Code they remain associated with Git.

Got it, thanks for the info! I will attempt to reproduce on a brand new Windows box, see what we can do.

Investigation

VSCode simply registers itself as an application suitable to open a variety of file types, through the use of the HKEY_CLASSES_ROOT registry subtree. Every time an application adds itself as one able to handle a file type, Windows will do the following:

  • If the file type itself doesn't have an application association set by the user, it will pick VS Code since it is the only alternative available.
  • Otherwise, it will not overwrite the association.

The exception to the rule seems to be files like *.js which seem to respect some strange _magic_ which I don't understand: they seem to be inherently associated with the Microsoft Windows Based Script Host through some other mechanism. As no one in their sane mind would actually expect to double click a .js file to run it in 2016, I'll let this slip. There may be others, but so far this is the one.

In conclusion, Code is doing the right thing, no change there.

The Rabbit Hole goes deeper

I've decided to experiment a bit more to find out how this works.

In a brand new VM, I installed Notepad++, created the following 4 files and associated *.config files to open with Notepad++.

image

Note that:

  • *.txt files are associated with Notepad.
  • *.sh files are not associated with any application, since there is no suitable application that can handle them.
  • *.js files are associated with the pesky Microsoft Windows Based Script Host.
  • *.config files are associated with Notepad++.

After, I installed the latest Insiders setup:

image

Everything is the same. Wait, what..? But Code did get registered to a few file extensions. Why?

image

After investigating why that is, it happens to be the PersistentHandler registry key. That seems to be the difference between *.sh and *.aspx files for example:

image

image

All the file extensions that were correctly associated with Code have this PersistentHandler set to some GUID, which was already there before Code's installation. I failed to understand where PersistentHandler comes from, and what its value actually means.

I stopped at this point, since I can think of more productive ways to spend my time.

Conclusion

I've added a checkbox during setup which will let users skip file associations: Register Code as an editor for supported file types.

@dbaeumer This is a new string that needs to be localised. The key is AssociateWithFiles, in build\win32\i18n\messages.en.isl.

VSCode Version: 1.4.0
OS Version: Win7 x64

After installing Visual Code, I don't know which file is .gitattributes, and which file is .gitignore ...
filename

although I added 'AlwaysShowExt' in filetype, but not working...
regedit

Assigning back to @joaomoreno to react to comments.

10694

I uninstall and re-install again, uncheck "Register Code as an editor supported file types", it is ok now.
2016-8-19 16-44-29

If I update from previous version (1.2.x), installer will associate filetypes.

Thanks.

Thank you!

Please add more options to set VSCode as default code editor, specially when switching from Sublime Text.

Like in Control Panel\Programs\Default Programs\Set Default Programs

That box needs to spell out what it is going to do and it should show _every_ association so we can untick ones we don't want. It is worded too vaguely.
The install removed my previously set up editor associations - they no longer appear under "open with". Very annoying.

...and it associates itself automatically with each and every file type it knows how to open on macOS. I love how VS Code thinks it is the only editor on my computer, but that's not the case.

How do I undo VSCode's damage on my Mac?

I still have this issue with macOS as well

Solution: Delete VSCode or move it away from /Applications

Yeah in the end I just deleted it and switched back to Sublime Text

Was this page helpful?
0 / 5 - 0 ratings

Related issues

misolori picture misolori  路  282Comments

Perkovec picture Perkovec  路  191Comments

Tyriar picture Tyriar  路  187Comments

ozsay picture ozsay  路  247Comments

hsdk123 picture hsdk123  路  263Comments