vscode: Mac shortcut not working (in vscode) [cmd+h or cmd+m]

  • VSCode Version: 1.60.1 ( Recent )
  • OS Version: Mac 11.15.2

Steps to Reproduce:

  1. On Release Note Screen
  2. (hide or minimize) cmd+h or cmd+m does not work (have not tried other shortcut).

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

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 110
  • Comments: 87 (5 by maintainers)

Most upvoted comments

I have a workaround:

Open command palette and search: Open Keyboard Shortcuts (JSON)

Then put this item in config file:

{
    "key": "",
    "command": "testing.toggleTestingPeekHistory"
}

Restart VSCode then it will be fine.

I’m having this issue everywhere in VSCode, regardless of the view or document open. Issue still occurs when all extensions are disabled.

VSCode Version: 1.56.2 MacOS 10.15.7

How many more comments and upvotes should this issue receive to get it fixed?..

Three years after reporting bug, I’m still having this issue.

Version: 1.59.1 Commit: 3866c35 Date: 2021-08-19T11:53:52.479Z Electron: 13.1.7 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Darwin x64 19.6.0

Got the same problem.

There is a osX workaround to hide the VS app. I leave this here maybe it helps someone.

use CMD + TAB keys to choose the VS code app keep pressing CMD and release the TAB key while holding down the CMD key hit H to hide the VS code app

Success! ✅ It’s working for me after:

  • Remove key binding for Toggle test history in peek
  • Restart vscode
  • cmd+h & cmd+m work now! 🎉

Would be nice if vscode didn’t overwrite this global keyboard shortcut though.


Edit: doesn’t work after a short while. Only works temporarily after restarting VS code - which is a less than ideal solution when using the integrated terminal for a long-running process 😒

Vielen Dank für Ihre E-Mail.

Die medienflieger sind unterwegs und ab dem 05.10.2021 wieder zu erreichen. Ihre E-Mail wird erst nach unserer Rückkehr bearbeitet.

Viele Grüße Tilman Behrend


Tilman Behrend | medienflieger GmbH | An der Sicker 7 | 97318 Kitzingen t: 09321.388 28 10 | f: 09321.388 28 09 www.medienflieger.de | @.***

I looked into this and created a PR for it. It does not make Cmd+H or Cmd+M work while in a webview (e.g. Markdown preview), but it does fix it breaking those keybindings until you reboot. More details are in the PR.

As a workaround until the PR is merged, you can make sure that you focus on a different editor before closing a Markdown preview. You can also use that trick to get it working again instead of having to completely restart VS Code if you accidentally do close the editor while focused on the webview.

I have reproduced this with markdown preview as well and noticed something that may help diagnose the issue.

From a markdown file (*.md), opening the markdown preview (I use a shortcut for the ‘Markdown > Open Preview to the Side’ command) will move focus to the newly opened markdown preview tab.

While the markdown preview tab is focused, Cmd+M does not function, but if I move focus back to the Editor for the markdown file (*.md), Cmd+M works again to minimize the window.

If the markdown preview tab is focused when the tab is closed, Cmd+M in that window will no longer function…until you re-open the markdown preview and move focus back out.

If the markdown preview tab is NOT focused when the tab is closed, Cmd+M in that window will continue to function properly thereafter.

It seems the markdown preview claims the key binding when focused, releases it upon blur, but does not release it upon close…or something to that effect (I’m just another user here).

I have also not been able to determine what markdown preview is doing with the Cmd+M binding (no visible effect is seen).

Success! ✅ It’s working for me after:

  • Remove key binding for Toggle test history in peek
  • Restart vscode
  • cmd+h & cmd+m work now! 🎉

Would be nice if vscode didn’t overwrite this global keyboard shortcut though.

Doesn’t fix it for me.

Yup doesn’t work for me either. It works initially because VS Code was restarted but after some time cmd + h no longer works again despite removing the key bindings.

Also couldn’t help but notice that this bug is as old as covid…

I was having this issue with the cmd + H shortcut, and this solved the issue for me.

Checking the VSCode keymaps, I figured out that this shortcut was assigned to another commanding within VSCode. After deleting the shortcut for the VSCode command and restarting VSCode, cmd + H came back to work to hide VSCode.

I’m unable to hide or minimize with cmd + h / cmd + m regardless of where I am in the editor.

VS Code Version: 1.58.2.

I’ve been feeling the Cmd+H / Cmd+M bug for a long time, I didn’t realize all this time that it was the markdown previewer! Glad we at least know where it’s coming from! I wish I could disable the previewer altogether given this effect — I don’t recall even using it. I usually stick to Typora…

Regardless — a note on workarounds

Sorry for overcomplicating the issue, but this only works for me when I move focus back to the Editor using ctrl+tab, not when switching tabs by clicking on them with the mouse.

I find this same behavior as well but I also realized that the “Double Click To Switch To Editor” feature also hands back focus in a way that resumes standard Cmd+H / Cmd+M control, and I believe this feature is on by default. Just open a markdown file, open the previewer, then double click anywhere in the previewer to hand focus back and get your keybindings back.

It’s almost funny. With both panes open you can click on the previewer, nothing works, double click it, key-binds work again, click the previewer and…they’re back off.

Thank you for pointing out this workaround. This has worked for me.

The workaround for anyone experiencing this issue with Markdown:

  1. Create new file (⌘+N or Ctrl+N).
  2. Change language mode to Markdown (⌘+P or Ctrl+P then select Change Language Mode).
  3. Open locked preview to side (⌘⇧+P or Ctrl⇧+P then select Markdown: Open Locked Preview to the Side)
  4. Double click anywhere on the locked preview.

Note: Ensure ‘Markdown > Preview: Double Click To Switch’ is enabled in settings.

Made no difference to me unfortunately. Not sure I remember that “toggle test history in peek” command being there when I first started experiencing the issue. It’s still a problem after viewing markdown preview in the VS Code window, such as the release notes.

Same problem for me in 1.62.2, annoying as hell :–( I had no idea I used to press ⌘H every minute or so. Please please fix!

I checked the keyboard shortcuts. By default a shortcut called “Test: Toggle Test History in Peek” is assigned to cmd + H. Maybe this isn’t a bug but rather a bad default keymap? One way or another, VSCode needs to fix this. Be it a bugfix or by changing the default assignment for that command.

@rkdmen could we rename the issue to clarify that these shortcuts are not just broken during webviews, but rather always? Just want to make sure it gets the attention it deserves 🙂 (and the VS Code team closed my other issue, that had a different title)

Ha, that seems to be the exact cause! Once I select Help > Release Notes, cmd+h, alt+cmd+h and cmd+m no longer work.

Success! ✅ It’s working for me after:

  • Remove key binding for Toggle test history in peek
  • Restart vscode
  • cmd+h & cmd+m work now! 🎉

Would be nice if vscode didn’t overwrite this global keyboard shortcut though.

Yes, this worked for me too. It also fixed “Hide others”, which is cmd + option + h. Thank you.

Restarting VS Code, whether you removed the default keymap or not, will always fix this issue.

The proposed keymap solution also doesn’t addressed the broken ⌘M behavior.

So I’m afraid I don’t think this solution is a viable workaround 😕

Still experiencing this on my machine. It is intermittent though and only happens after VSCode has been running for some time. If I quit and restart the VSCode, the Cmd-H works as expected for some period of time afterward.

Version: 1.60.2
Commit: 7f6ab5485bbc008386c4386d08766667e155244e
Date: 2021-09-22T11:59:27.195Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0

Confirmed that the bug @jacobweber referenced above almost 3 months ago is still occurring in Visual Studio Code 1.61.1.

Version: 1.60.1 Commit: 83bd43bc519d15e50c4272c6cf5c1479df196a4d Date: 2021-09-10T17:09:14.403Z Electron: 13.1.8 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 20.6.0

@mjbvz Would you please consider increasing the priority of this issue, as it has been affecting users for quite some time (worsened by the Webview changes a few months back)?

I’ve been feeling the Cmd+H / Cmd+M bug for a long time, I didn’t realize all this time that it was the markdown previewer! Glad we at least know where it’s coming from! I wish I could disable the previewer altogether given this effect — I don’t recall even using it. I usually stick to Typora…

Regardless — a note on workarounds

Sorry for overcomplicating the issue, but this only works for me when I move focus back to the Editor using ctrl+tab, not when switching tabs by clicking on them with the mouse.

I find this same behavior as well but I also realized that the “Double Click To Switch To Editor” feature also hands back focus in a way that resumes standard Cmd+H / Cmd+M control, and I believe this feature is on by default. Just open a markdown file, open the previewer, then double click anywhere in the previewer to hand focus back and get your keybindings back.

It’s almost funny. With both panes open you can click on the previewer, nothing works, double click it, key-binds work again, click the previewer and…they’re back off.

@ryanswanson

While the markdown preview tab is focused, Cmd+M does not function, but if I move focus back to the Editor for the markdown file (*.md), Cmd+M works again to minimize the window.

Sorry for overcomplicating the issue, but this only works for me when I move focus back to the Editor using ctrl+tab, not when switching tabs by clicking on them with the mouse.

Even more strangely: moving focus back to the editor only re-enables cmd+m/cmd+h if, while switching tabs using ctrl+tab, I press ctrl+tab such that the tab switcher pops up; then hold down the ctrl key for a short while, and only then release the ctrl key. Only if I hold down the ctrl key for long enough, such that the tab switcher is open for a while, do the window keyboard shortcuts work again. Some very rudimentary testing using a metronome seems to indicate that the ‘activation threshold’ is around 200-300 ms.

Can anyone reproduce this bizarre behaviour?

Version: 1.64.2

It also reproduces and VERY frustrating(

Not for me – opened and closed Git Graph, and command-H stopped working.

Version: 1.61.1 Commit: c13f1abb110fc756f9b3a6f16670df9cd9d4cf63 Date: 2021-10-14T01:23:30.274Z (23 hrs ago) Electron: 13.5.1 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 18.7.0

Hello. it is still there and it is very annoying. If I am in a web view, cmd-H will not hide the application, and I am forced to click in a text pane first.

I am using VS Code 1.81 and VSCodium 1.80 under macOS Sonoma

Thank you @ssigwart! The pull request is here for those interested in more details: https://github.com/microsoft/vscode/pull/154648

I have a workaround:

Open command palette and search: Open Keyboard Shortcuts (JSON)

Then put this item in config file:

{
    "key": "",
    "command": "testing.toggleTestingPeekHistory"
}

Restart VSCode then it will be fine.

Thanks, it worked for me!

I have a workaround:

Open command palette and search: Open Keyboard Shortcuts (JSON)

Then put this item in config file:

{
    "key": "",
    "command": "testing.toggleTestingPeekHistory"
}

Restart VSCode then it will be fine.

FINALLY!! thank you!

I can also reproduce. The issue persists even after closing the markdown preview. It does not, however, persist when I close the window without quitting the app.

For everyone noticing it starts then stops working, can we check whether this coincides with displaying a markup document (such as the new version readme which automatically appears when VSCode updates itself)?

This appears to be working now, for both Cmd+H (Hide Visual Studio Code) and Opt+Cmd+H (Hide Others).

Version: 1.61.1 Commit: c13f1abb110fc756f9b3a6f16670df9cd9d4cf63 Date: 2021-10-14T01:23:30.274Z Electron: 13.5.1 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 20.6.0

Happens with current latest version 1.59.0 under macOS Catalina (10.15.7) just with normal code views. Maybe related to the display of the changelog after update. App restart does fix this behavior for me.

Moved here, for a better title and visibility:

https://github.com/microsoft/vscode/issues/130194

me too…

I can not hide my vsc by Command + H.

And I’ve been annoyed by this problem for a looooong time…

I have the issue as well but the workaround doesn’t work for me as testing.isPeekVisible has never been set to cmd+h in the first place, it’s set to opt+h. There is no shortcut set for cmd+h at all anywhere and still it fails for certain windows while it works for other windows. Also the window it fails has never been a markup preview, it’s an editor editing a shell script and never has been anything else. Two other open windows work as expected.

Same for me. I can’t find “cmd+h” but hiding vscode does not work.

I have a workaround:

Open command palette and search: Open Keyboard Shortcuts (JSON)

Then put this item in config file:

{
    "key": "",
    "command": "testing.toggleTestingPeekHistory"
}

Restart VSCode then it will be fine.

I’ve had this item in my config for a while, but still ran into this bug today. Restarting VS Code obviously did temporarily fix the issue, but that’s not exactly a viable workaround…

My workaround is to just define a Keyboard Maestro macro for command-H that hides VSCode. Not perfect, but it works.

I’m able to reproduce that bizarre behavior as well, but cmd+h/cmd+m both break after I open up a Markdown preview.

Version: 1.65.2 Commit: c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1 Date: 2022-03-10T14:33:49.188Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 21.4.0

Success! ✅ It’s working for me after:

  • Remove key binding for Toggle test history in peek
  • Restart vscode
  • cmd+h & cmd+m work now! 🎉

Would be nice if vscode didn’t overwrite this global keyboard shortcut though.

Doesn’t fix it for me.

Worked for me, I might suggest that you reset all of your keybindings for VScode and MacOS to defaults and then erase the suggested keybinding.

@jokocide Are you sure this fixed it persistently and not just for a few hours?

I noticed that it stopped working the next morning, but closing and re-opening VScode restored functionality again.

image image changing these key bindings could fix the problem

Version: 1.62.3 Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247 Date: 2021-11-17T07:59:13.865Z Electron: 13.5.2 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 21.1.0

same here

For me cmd + h works after launching the vscode but after few hours, it stops working. I have to restart to make it work again.

Version: 1.62.3 Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247 Date: 2021-11-17T08:14:33.711Z (1 wk ago) Electron: 13.5.2 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin arm64 21.1.0

For me cmd + h works after launching the vscode but after few hours, it stops working. I have to restart to make it work again.

Version: 1.62.1 Commit: f4af3cbf5a99787542e2a30fe1fd37cd644cc31f Date: 2021-11-05T09:23:14.144Z (6 days ago) Electron: 13.5.2 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 20.6.0