Skip to content
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

Add an option to confirm before quitting #14710

Closed
billsworld opened this issue Oct 30, 2016 · 93 comments
Closed

Add an option to confirm before quitting #14710

billsworld opened this issue Oct 30, 2016 · 93 comments
Assignees
Labels
feature-request Request for new features or functionality on-release-notes Issue/pull request mentioned in release notes on-testplan workbench-window Window management
Milestone

Comments

@billsworld
Copy link

  • VSCode Version: 1.6
  • OS Version: OSX Sierra

Many times on a Mac it is necessary to use cmd+`` to navigate between projects. This can lead to a mishit on cmd+q` very easily. It would be great to have a confirm quit feature. Something like this sublimetext extension https://github.com/xavi-/sublime-maybs-quit

Thanks!

@roblourens
Copy link
Member

roblourens commented Oct 31, 2016

I've also wanted this - I really like the Chrome option that requires you to hold cmd+q, or double tap, to actually quit. I cmd+w and cmd+tab a lot, rarely cmd+q on purpose.

@roblourens
Copy link
Member

And you can't just remap it, as it's handled by electron

@bpasero
Copy link
Member

bpasero commented Oct 31, 2016

As a workaround you could at least map Cmd+Q to something else or unbind it?

@bpasero bpasero added feature-request Request for new features or functionality workbench labels Oct 31, 2016
@bpasero bpasero removed their assignment Oct 31, 2016
@bpasero bpasero changed the title Confirm Quit Add an option to confirm before quitting Oct 31, 2016
@AndrewRayCode
Copy link

AndrewRayCode commented Jul 20, 2017

Wanted to point out that if you accidentally command Q with an unsaved file open, the file state is preserved on re-opening VSCode, but all undo history is lost, so not having this feature can destroy user data.

@obahareth
Copy link

I found this extension that adds a "confirm before quit" functionality that solved this for me.

@gcphost
Copy link

gcphost commented Apr 13, 2018

Thanks @obahareth, this just got me again today.

@prodrammer
Copy link

Despite the existence of cmd+shift+w, I like to spam cmd+w while listening to loud rock music to close files. This typically results in also closing the entire app. The above extension mentioned by @obahareth works like a charm.

@roblourens
Copy link
Member

Is there an extension for the rock music though?

@prodrammer
Copy link

prodrammer commented May 3, 2018

Ask and ye shall receive. Now I just need an extension that deposits money directly into my account...

@CasperPas
Copy link

 It would be great if we have an option that requires us to hold Cmd + Q to quit, like the way Chrome does

@gregmarr
Copy link

I just had VSCode exit on me while debugging because I hit Cmd-Q instead of Cmd-Tab. Really annoying. Going to check out this extension!

@adamdawkins
Copy link

I regularly have multiple instances open with different servers/processes running and it's annoying it's so easy to close the app. Have just installed installed the extension; seems to be the solution 👍

@rowild
Copy link

rowild commented Aug 12, 2018

This option is really a must! Every other good IDE (and other programs) has a "warn on quit" function already integrated - so VSCode shouldn't step out of line of "good IDE behaviour", IMO.
VSCode-Team: please add an option for that! Thanks a lot!

@kAlvaro
Copy link

kAlvaro commented Sep 13, 2018

The Quit Control for VSCode extension mentioned here is useful but it only addresses accidental keystrokes and not all (you can still close your workspace by inadvertently hitting e.g. Alt+F4 instead of Ctrl+F4). Perhaps the extension API does not even allow that :-?

I think a builtin "Prompt before exit" feature still makes sense if it's granular enough to tell workspace windows apart. That would allow to still be able to close quickly random files but get a prompt on folders
(or viceversa).

@taroee
Copy link

taroee commented Sep 19, 2018

Another case.
I also accidentally pressed Alt + F4, Ctrl + W, and clicking close buttons rapidly on all maximized window sometimes and accidentally closes VSCode too.
hotExit is helpful, but sometimes we need to undo/redo our code (undo, then build, refresh, redo, then build, refresh) and we cannot undo/redo once the text editor was closed.
It will be convenient and save a lot of time for us if VSCode provide the option to (always) prompt user before exit to prevent closing VSCode accidentally.

Thanks team.

@masbaehr
Copy link

masbaehr commented Dec 4, 2018

and clicking close buttons rapidly on all maximized window sometimes and accidentally closes VSCode too.

Yea that happened to me as well.
Please add such a feature

@chaseWillden
Copy link

Please add!

@niccolomineo
Copy link

Chrome's way of handling this is genius as it is. I am supporting the one who suggested it for VSCode!

@figalex
Copy link

figalex commented Jan 8, 2019

Please add something like this, I keep hitting CMD+w by mistake! so annoying...

@schester44
Copy link

+1

@dnsampaio
Copy link

Please add.

@artdiniz
Copy link

artdiniz commented Oct 19, 2021

@bpasero What about an API that allows an extension to respond to an action that would close the IDE? Given the variety of preferences/complaints, this seems like a good extension candidate. With an explicit quit-/close-confirmation API, it would be easy to make various extensions to enable exactly the behavior the user wants. Obviously there's Quit control, but that works by overriding keybindings, which strikes me as rather fragile - if VSCode or the user changes the relevant keybindings, quit control will break.

@firelizzard18 Yep, that's the next big thing I would love to change in the extension: not depending on overwriting keybindings
@bpasero It would be really useful to be able to intercept commands as a new Contribution Point. Right now Quit Control creates new commands for "Quit" and "Close Window" and assigns shortcuts to them. The extension then triggers the commands workbench.action.quit or workbench.action.closeWindow accordingly.

As I see it, the extension's contribution points would be better as two "command interceptors" and not as a bunch of "keybindings" that point to new "commands" depending on the platform, so users don't need to change any of the keybindings they already have for "Quit" and "Close Window". Quit control would just intercept workbench.action.quit and workbench.action.closeWindow and cancel them or not, depending on the situation.


The Quit Control for VSCode extension mentioned here is useful but it only addresses accidental keystrokes and not all (you can still close your workspace by inadvertently hitting e.g. Alt+F4 instead of Ctrl+F4). Perhaps the extension API does not even allow that :-?

I think a builtin "Prompt before exit" feature still makes sense if it's granular enough to tell workspace windows apart. That would allow to still be able to close quickly random files but get a prompt on folders (or viceversa).

Quit Control handles Alt+F4 on Windows now. But on Ubuntu (maybe on other linux distros too), VScode seems not to be able to assign anything to Alt+F4. Maybe that's another place where "Command Interceptors" might be useful.

@akharrou
Copy link

akharrou commented Dec 13, 2021

Here's another workaround: binding quit action to cmd+q q/cmd+q cmd+q which forces you to have to press it twice, almost identical to chrome imo.

// keybindings.json
{ "key": "cmd+q q", "command": "workbench.action.quit" },
{ "key": "cmd+q cmd+q", "command": "workbench.action.quit" },

And with these settings as suggested above, you should be almost guaranteed to not accidentally close vscode.

// settings.json
"files.hotExit": "off",
"terminal.integrated.showExitAlert": true,
"terminal.integrated.confirmOnExit": "always",
  • as a bonus you get a new set of possible shortcuts w/ cmd+q as the leader key.

That said I'm still a proponent for this feature being implemented if possible.

@cha2hyun
Copy link

cha2hyun commented Jan 4, 2022

use 'Quit Control for VSCode' Extension to prevent accidental close

Name: Quit Control for VSCode
Id: artdiniz.quitcontrol-vscode
Description: Stop mistyping keyboard shortctus that close/quit VSCode unintentionally
Version: 4.0.0
Publisher: Artur Diniz Adam
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=artdiniz.quitcontrol-vscode

@andre-mr
Copy link

andre-mr commented Jan 30, 2022

I'd love to have a global option to just confirm quitting vscode. Like IntelliJ has. No need for extensions, woakarounds, and many confusing options, just a global toggle option for a modal: "Exit VSCode? Yes/Cancel/Disable this message". As simple as that, regardless if using ctrl+w, alt+f4 or clicking "x" button.

I came here because just today i missed the mouse click because of higher screen resolution and windows overlay, and boom! VSCode was accidentally closed. This doesn't happen with IntelliJ because i keep confirmation option activated.

Just a little dissapointed since this issue is from 6 years ago, but...
Thanks to developers if such feature can be added.

@prodrammer
Copy link

@andre-mr Welcome to the "I wish vscode had an option to confirm before quitting" family!

@rkulla
Copy link

rkulla commented Mar 15, 2022

+1

@turbolocust
Copy link

Please add this. I mean, how difficult can it be?

@mountainash
Copy link

Please add this. I mean, how difficult can it be?

Probably not that difficult... it's open source software, so why don't you find out and submit a PR so we can all gain from it (rather than not-one-single-person gaining anything from your comment)?

@andre-mr
Copy link

andre-mr commented Apr 3, 2022

i believe it may be that hard.

because it's a 6 years old discussion, and the only pull request i found was closed 2 years ago.

maybe it's out of vscode side, i think of electron or something. i honestly don't know how it works and don't have time to help for now, but it seems i am not the only one.

and i would be grateful if someone finds a solution to include in official release.

:)

@turbolocust
Copy link

turbolocust commented Apr 4, 2022

Please add this. I mean, how difficult can it be?

Probably not that difficult... it's open source software, so why don't you find out and submit a PR so we can all gain from it (rather than not-one-single-person gaining anything from your comment)?

Well, easier said than done. Having none to little experience with this project and Electron I believe it would take me quite a lot of time to get this done in comparison to someone who is an expert. I know my comment was not constructive, however my only intention was to push this topic in terms of prioritisation.

@leewp14
Copy link

leewp14 commented Apr 5, 2022

Same thoughts. Simple google search seems to indicate such. There's even sample codes and demo GIFs on stackoverflow. The exit event is also documented in electron docs.
It would be great if someone could shed some light on this (maybe @bpasero ?), and have this issue closed if it is really not possible - but with the underlying reasons. Since this issue was created so many years back and still open.
Again, like @MutableLoss , I don't know anything about electron and vscode source, and probably there's a reason for this longstanding issue. @bpasero actually replied on the previous PR that he might work on this, and closed the PR. However it seems like there's nothing referencing that PR so it's not clear if it is being worked on, or any issues with this.

I'm a bit perplexed this request has lasted so long, especially when the implementation in Electron only requires interception of the close event, and doing whatever you want to prompt to the user before ever telling Electron to unload. Of course, I know nothing about the VSCode source, so surely there is a reason.

@leewp14
Copy link

leewp14 commented Apr 5, 2022

I think here's a possible workaround - launch terminal automatically, and enable confirm on exit when there's terminal session, provided that you don't mind having terminal open on launch. I use terminal everytime so this is just perfect for me. If you don't use terminal, just close the terminal window (x button, not the trash button), the terminal will stay active in background as it just hides it.

Install this extension to autorun terminal:
https://marketplace.visualstudio.com/items?itemName=fabiospampinato.vscode-terminals
Set the following in the extension settings (Ctrl+Shift+P, run Terminals: Edit Configuration) to open a simple, ordinary terminal on every startup:
{ "autorun": true, "terminals": [ { "open": true } ] }

Then, enable Confirm On Exit under Features>Terminal in vscode settings.

@ddehghan
Copy link

ddehghan commented Apr 8, 2022

Came to upvote this and see that I have already done it years ago. :-(

@bpasero
Copy link
Member

bpasero commented Apr 11, 2022

Took a second attempt at this, given we meanwhile had added support for window.confirmBeforeClose in web. The idea would be to allow this setting on desktop too.

At first I was thinking about adding 2 settings - one for closing a window and one for quitting the application - but not sure that is necessary. The setting covers both window close and quit with a dialog to confirm the operation.

Setting to keyboardOnly will only bring up the dialog when a keybinding was used (such as Cmd+Q or Ctrl+W) and setting to always will cover mouse interactions too (e.g. from the menu or the window close button).

Recording 2022-04-11 at 10 16 39

Thoughts?

@hrasoa
Copy link

hrasoa commented Apr 11, 2022

Looks good! In addition, I would add these scenarios on keyboardOnly:

  • cmd+q: prompt the user.
  • long press on cmd+q: no prompt, just quit.

@bpasero
Copy link
Member

bpasero commented Apr 11, 2022

cmd+q prompt the user.

Yeah that is covered.

long press on cmd+q: no prompt, just quit

We do not have the infrastructure for long press. What is possible is to add another command to quit/close without confirmation but going through the hassle of configuring another keybinding for that you could as well just change the existing keybinding to a chord (as outlined here in many comments)?

@turbolocust
Copy link

I would make 'always' the default in a fresh installation since the prompt allows one to set a default by "not asking again".

@bpasero
Copy link
Member

bpasero commented Apr 12, 2022

This is now available in insiders for testing when setting window.confirmBeforeClose. You can give our preview releases a try from: https://code.visualstudio.com/insiders/

@nikoladev
Copy link

Tried it out on the insiders version. It works.

Thanks very much!

@bpasero bpasero closed this as completed Apr 13, 2022
@bpasero bpasero added on-testplan on-release-notes Issue/pull request mentioned in release notes labels Apr 19, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality on-release-notes Issue/pull request mentioned in release notes on-testplan workbench-window Window management
Projects
None yet
Development

Successfully merging a pull request may close this issue.