I guess it's not possible to catch the ctrl+w shortcut before the browser interprets it, but would it be possible to show a "leave this page?" confirmation dialog to prevent the good old muscle memory from screwing up ones work?
Will definitely add this!
Can you use Ctrl + W to close editor tabs or some other VSCode functions?
And I think it's better to close browser tab (maybe with confirmation) if any editor tabs are opened.
Hotkey should be consistent with VSCode to get an immersive experience.
Will definitely add this!
Important to have a page in the documentation listing all the default code-server shortcuts
Right now when I press Ctrl + W it closes the browser tab, instead of closing the file. Since I used to close files using this in real VS Code, we need to find a solution for this
we could use something like
window.onbeforeunload = function (e) {
// Cancel the event
e.preventDefault();
// Chrome requires returnValue to be set
e.returnValue = 'Really want to quit the game?';
};
It doesn't prevent from closing, but at least show you an additional confirmation
It totally closes the tab for me.
Chrome: Version 80.0.3962.2 (Official Build) dev (64-bit)
Code Server: 2.1692-vsc1.39.2
I didn't unassign anyone :thinking:
@MicroDroid unfortunately we can't solve this - I believe this is also persistent in upstream VSCode so this is more of a by-design since you can't override Ctrl-W as far as I investigated.
Perhaps we can at least show a confirmation dialog?
I think we did that over in Theia, not sure how we want it on VSCode though.
Feel free to bring this up to Microsoft as well.
CC @code-asher what do you think?
Hmm we used to do this but then it kept popping up when it wasn't needed like when using full-screen or an app window. If there's a way to distinguish between those states then we could put it back in. But maybe it'd be more proper for the change to be made upstream.
The beforeunload should do it.
The problem we ran into was that if you run something like this:
chrome --app=http://my.ide.com
Then ctrl+w works as expected so we don't need beforeunload. But then when you try to close the application the beforeunload prevents you from doing so and forces you to confirm which users reported as jarring.
So we'd just need a way to detect if code-server is running in an app window (or full-screen because it should have the same behavior) and in that case elect not to prevent the window close.
Most helpful comment
Will definitely add this!