Microsoft/vscode

`code` CLI still opens duplicate VSCode instance in the macOS dock

Open

#139,634 opened on 2021年12月22日

GitHub で見る
 (34 comments) (30 reactions) (1 assignee)TypeScript (74,848 stars) (10,221 forks)batch import
bughelp wantedmacosworkbench-os-integration

説明

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 to open) but doesn't work at all.
  • Using open a wrapper for as a workaround for code breaks non-file arguments — even code --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

Item Value
CPUs Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)
GPU Status 2d_canvas: enabledgpu_compositing: enabledmetal: disabled_offmultiple_raster_threads: enabled_onoop_rasterization: enabledopengl: enabled_onrasterization: enabledskia_renderer: disabled_off_okvideo_decode: enabledwebgl: enabledwebgl2: 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%
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
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

コントリビューターガイド