Skip to content

prevent ctrl+w from closing tab #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
herrgahr opened this issue Mar 6, 2019 · 14 comments
Closed

prevent ctrl+w from closing tab #53

herrgahr opened this issue Mar 6, 2019 · 14 comments
Labels
enhancement Some improvement that isn't a feature
Milestone

Comments

@herrgahr
Copy link

herrgahr commented Mar 6, 2019

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?

@kylecarbs
Copy link
Member

Will definitely add this!

@nhooyr nhooyr added the enhancement Some improvement that isn't a feature label Mar 8, 2019
@odiak
Copy link

odiak commented Mar 10, 2019

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.

@jeasonstudio
Copy link
Contributor

Hotkey should be consistent with VSCode to get an immersive experience.

@avelino
Copy link
Contributor

avelino commented Mar 10, 2019

Will definitely add this!

Important to have a page in the documentation listing all the default code-server shortcuts

@gijo-varghese
Copy link

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

@gijo-varghese
Copy link

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

@kylecarbs kylecarbs added this to the April 2019 milestone Apr 8, 2019
@kylecarbs kylecarbs assigned nol166 and unassigned code-asher Apr 8, 2019
@code-asher
Copy link
Member

Fixed with #463.

@MicroDroid
Copy link

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

@MicroDroid
Copy link

I didn't unassign anyone 🤔

@sr229
Copy link
Contributor

sr229 commented Dec 5, 2019

@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.

@MicroDroid
Copy link

Perhaps we can at least show a confirmation dialog?

@sr229
Copy link
Contributor

sr229 commented Dec 5, 2019

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?

@code-asher
Copy link
Member

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.

@code-asher
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Some improvement that isn't a feature
Projects
None yet
Development

No branches or pull requests