Vscode: VS Code takes over the association for HTML files without asking

Created on 11 Oct 2018  路  18Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.28.0, v1.29.0-insider, commit f151c46b1783cf4f9a4ca934a85f78846f08688e.
  • OS Version: Linux Mint 18. uname -a reports: "Linux 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux"

Steps to Reproduce:

  1. Double-click an HTML file to check that your browser has the association for HTML files.
  2. Run VS Code, then close it.
  3. Double-click an HTML file. It opens in VS Code instead of the browser. Close VS Code.
  4. Reset the HTML association to the browser.
  5. Run VS code, then close it.
  6. Double-click an HTML file. It opens in VS Code instead of the browser.

Does this issue occur when all extensions are disabled?: Yes

Additional info:

This bug does not happen in version 1.27.2.

When I installed 1.28.0 over 1.27.2, this error appeared in the terminal:

/usr/share/applications/code-url-handler.desktop: warning: key "MimeType" is a list and does not have a semicolon as trailing character, fixing

Installing over 1.27.2 is not necessary. I uninstalled VS Code, then installed 1.28.0, and the bug still happens.

I can work around this problem by deleting /usr/share/applications/code-url-handler.desktop. I don't know if this will have unwanted side-effects, though.

bug install-update linux verified

Most helpful comment

I can reproduce this with Ubuntu 18.04 and VSCode 1.28.1. mv /usr/share/applications/code-url-handler.desktop /usr/share/applications/code-url-handler.desktop~ does indeed help.

All 18 comments

I can reproduce this with Ubuntu 18.04 and VSCode 1.28.1. mv /usr/share/applications/code-url-handler.desktop /usr/share/applications/code-url-handler.desktop~ does indeed help.

I can reproduce this with Ubuntu 18.04 and VSCode 1.28.1. mv /usr/share/applications/code-url-handler.desktop /usr/share/applications/code-url-handler.desktop~ does indeed help.

Debian testing and VSCode 1.28.1 no effect, delete is also

o 锛宒elete .local/share/applications/code-url-handler.desktop锛宒oes indeed help.

Will this problem be fixed? Or the final solution is delete .local/share/applications/code-url-handler.desktop?

It will be fixed.

Same problem on Ubuntu 18.10, vscode 1.28.2 installed from .deb .
Fixed with :

sudo rm /usr/share/applications/code-url-handler.desktop

This seems to be caused by calling app.setAsDefaultProtocolClient here: https://github.com/Microsoft/vscode/blob/b7eb0f4040f4eaf72275d512c3ce431103f6e3cf/src/vs/platform/url/electron-main/electronUrlListener.ts#L45

We don't really need this call in macOS or Linux, so now we just run it for Windows.

The original issue doesn't repo on my Linux / Mac.

This is Linux only! Basically:

  1. Create a file.html file on the Desktop
  2. Install the Code deb package
  3. Associate file.html to open with Firefox. Verify by double clicking on it.
  4. Run Code
  5. Double click file.html. It should keep opening in Firefox.

1.28.2 did not associate the file with Code under Ubuntu 18.04. Trying with Fedora now.

This occurs to me with 1.28.2 on Fedora. Installed code-1.28.2-1539736121.el7.x86_64 from the official yum repository. Every time Code is started, the XDG default for MIME type text/html gets overridden to code-url-handler.desktop. This is very annoying and invasive, don't do it from an application.

@mzabaluev Does it add the association back when you remove it manually? If so, could you try the latest insiders build and check if it is fixed? Thanks.

Does it add the association back when you remove it manually?

It does.

If so, could you try the latest insiders build and check if it is fixed?

It seems fixed in code-insiders-1.29.0-1541336700.

Thanks @mzabaluev. Marking verified.

This is fixed in 1.29, thanks!

@acidhelm I鈥檓 still seeing this behaviour on Pop!_OS 18.10 (based on Ubuntu 18.10) with VSCode 1.29.1.

OS: Ubuntu 18.04

Updating to 1.29.1 doesn't resolve the issue. Cc. @chrmarti

In my case, if I open with
$ xdg-open file.html
it will be opened in default web application set by user.

But if I open with elevated privilege
$ sudo xdg-open file.html
it will be opened in vs-code

So, I think vs-code override _su_(?) default html opener at the past installation.
Is there any way to revert this?

Deleting code-url-handler.desktop does help stop this vs-code popup behavior (for user with elevated privilege), but it still doesn't open the html in default web application.
I believe what users expect is it to be opened in default web application whether it opened by a normal user or with the elevated one.

1.29.1 does not solve this issue for me either.

Ubuntu 16.04, using xdg-open file.html opens vscode instead of default browser.

Ubuntu 18.04.1
VS Code 1.29.1

VS Code team - this really sucks don't make me start hating this great product please
(Workaround $ sudo rm /usr/share/applications/code-url-handler.desktop still working for me btw)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipgiuliani picture philipgiuliani  路  3Comments

lukehoban picture lukehoban  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

chrisdias picture chrisdias  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments