madskristensen / Tweakster

A Visual Studio extension
Apache License 2.0
241 stars 23 forks source link

If Ctrl+W already bound to Window.CloseDocumentWindow, pressing it closes two documents #22

Closed ChayimFriedman2 closed 4 years ago

ChayimFriedman2 commented 4 years ago

I've installed this (great!) extension, and got a strange behavior: pressing Ctrl+W closes two documents (if open).

One clue was that they wasn't being closed in parallel, but one after one, like someone pressed Ctrl+W twice instead of one.

In the start, I suspected my keyboard is the reason. But Ctrl+F4 worked great.

I wanted to report it to Developer Community, so I opened VS in Presentation Mode, but suddenly the problem disappeared.

I changed the relevant settings of Presentation Mode, still problem refuse to reproduce.

I opened VS in Safe Mode, and problem still not there. Here I understood that one of my extensions was the factor.

So I started exploring my extensions, and found this one. I forgot that I installed it, so I took a look at its documentation. And I saw it changes the behavior of Ctrl+W to close the current document. Great, I thought, I already had that in my VS. VS Code and Chrome, you know... All use Ctrl+W.

Just a moment - did I have it before? Maybe this is the cause? So I removed my custom keyboard shortcut, and problem disappeared!

TL;DR: This extension still executed Ctrl+W shortcut, which causes bugs if it closes document.

The simple fix will be to define Ctrl+W as a VS shortcut and not custom code; However, this will force us to save the previous shortcut in order to restore it in case of uninstallation. Another, somewhat more complicated fix, will be to not execute the code if Ctrl+W already bound to Close Document.

ghost commented 4 years ago

I hit this problem too so ended up removing the CTRL+W keyboard mapping and just relying on Tweaks.

ChayimFriedman2 commented 4 years ago

@danielgreen-nes This is what I did too, but this is still a bug 😃