vscode: `code` CLI still opens duplicate VSCode instance in the macOS dock
Issue Type: Bug This is a re-file of https://github.com/microsoft/vscode/issues/60579, which does not appear to be fixed for me in the November VSCode release.
VSCode is still opening processes with duplicate dock icons (and therefore slowing down the use of code
to open files). Judging from the issue and the accompanying PR, it looks like I’m not the only one who is still experiencing this issue. Unfortunately, the other issues and PRs are closed and locked, so I’m filing this new one.
Simple repro: code new-file.txt
One workaround from the other issue was to use open -b com.microsoft.VSCode
. However, this has some challenges:
- The
open
command completely fails on macOS if passed any file that does not exist yet. This makes the raw command useless for creating new files from the commandline. 😔open -b com.microsoft.VSCode new-file
outputs:The file /Users/lgarron/new-file does not exist.
- It is not obvious how to craft a shell function wrapper that properly opens files, can handle multiple paths (files or folders), and isn’t subject to edge cases and injections (e.g. file names that will be confused for arguments to
open
).open -b com.microsoft.VSCode --args new-file
does nothing, outputs nothing, and exits without an error. Leaving out--args
is unsafe (when the file name is not typed by hand and known not to conflict with an argument toopen
) but doesn’t work at all.
- Using
open
a wrapper for as a workaround forcode
breaks non-file arguments — evencode --help
. - In addition to setting an alias/function for
code
in your shell, you will need to set up$EDITOR
separately (at least in some shells).
A proper fix would be really appreciated.
VS Code version: Code 1.63.2 (899d46d82c4c95423fb7e10e68eba52050e30ba3, 2021-12-15T09:37:28.172Z) OS version: Darwin x64 21.2.0 Restricted Mode: No
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i9-8950HK CPU @ 2.90GHz (12 x 2900) |
GPU Status | 2d_canvas: enabled gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled webgl: enabled webgl2: enabled |
Load (avg) | 4, 3, 3 |
Memory (System) | 32.00GB (0.14GB free) |
Process Argv | –crash-reporter-id 98789cd9-b9d1-4ac0-b09a-99c0a9d11695 |
Screen Reader | no |
VM | 0% |
Extensions (12)
Extension | Author (truncated) | Version |
---|---|---|
custom-window-zoom | cra | 1.1.4 |
vscode-eslint | dba | 2.2.2 |
prettier-vscode | esb | 9.0.0 |
codespaces | Git | 1.4.2 |
vscode-pull-request-github | Git | 0.34.2 |
go | gol | 0.30.0 |
jupyter-keymap | ms- | 1.0.0 |
vsliveshare | ms- | 1.0.5200 |
vs-code-prettier-eslint | rve | 3.0.4 |
fish-vscode | sky | 0.2.1 |
shellcheck | tim | 0.18.3 |
vscode-status-bar-format-toggle | tom | 3.0.0 |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
pythontb:30283811
pythonvspyt551:30345470
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscoreces:30384385
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
vscop804:30404766
vscop341:30404997
vsrem710cf:30416617
vscexrecpromp3t2:30407763
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 19
- Comments: 25 (2 by maintainers)
Commits related to this issue
- [config.fish] `code`: Touch all files as a workaround for https://github.com/microsoft/vscode/issues/139634 — committed to lgarron/dotfiles by lgarron 3 years ago
- [config.fish] Set `$EDITOR` to `open -b com.microsoft.VSCode`. This is a workaround for https://github.com/microsoft/vscode/issues/139634 — committed to lgarron/dotfiles by lgarron 2 years ago
- [config.fish] Remove the `code` wrapper function. This was causing more issues than it solves. Until https://github.com/microsoft/vscode/issues/139634 is fixed, I'll just have to live with slowness a... — committed to lgarron/dotfiles by lgarron 2 years ago
I solved it on my machine with this:
alias code="open -b com.microsoft.VSCode"
Not really an actual solution. But this was annoying to me.
I had the same problem and I used the “Extension Bisect” feature to find the culprit.
In my case it was the extension “Spell Right”. I’m posting an issue on their repo: https://github.com/bartosz-antosik/vscode-spellright/issues/497
In your Mac Dock Settings, disable the recent apps in the dock and it will work just fine 👍
I can replicate this with zero extensions enabled, as long as Code is running.
In other words:
code .
from Terminalcode .
I’ve had recent apps disabled in the dock for a long time. It didn’t help for me a year ago and still doesn’t help now, unfortunately. The bug still persists.
For what it’s worth, I’ve personally had the recent apps section disabled for a long time, and it seems to be unrelated to this issue (which is still happening, and I’ve just learned to grit my teeth and live with the slight slowdown and extra visual distraction of using the original
code
binary as my editor so that I don’t have to deal with the bugs and security issues of the workaround alternatives).