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

VS Code doesn't prompt on close if a file has been changed #21228

Closed
rchiodo opened this issue Feb 22, 2017 · 10 comments
Closed

VS Code doesn't prompt on close if a file has been changed #21228

rchiodo opened this issue Feb 22, 2017 · 10 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Feb 22, 2017

  • VSCode Version: Code 1.9.1 (f9d0c68, 2017-02-09T00:26:45.394Z)
  • OS Version: Windows_NT ia32 10.0.14393
  • Extensions:
Extension Author Version
cpptools ms-vscode 0.10.1
csharp ms-vscode 1.7.0
PowerShell ms-vscode 0.9.0
debugger-for-chrome msjsdiag 2.5.3
cmake twxs 0.0.15
cmake-tools vector-of-bool 0.9.2

Steps to Reproduce:

  1. Open a file from windows explorer into VS Code
  2. Edit the file
  3. Close the file.
  4. No prompt for save.
@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 22, 2017

Then if I open the file again, VS code opens two windows. One with the change I made, and one without.

@roblourens
Copy link
Member

The first thing you describe is expected behavior. It can be controlled with the files.hotexit setting.

The second, are you saying that VS Code opens two windows with the same file, and only one instance has the change?

@roblourens roblourens added the info-needed Issue requires more information from poster label Feb 23, 2017
@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 23, 2017

Why would it not ask for a file I changed? That seems busted to me. I think I may switch my default editor back to notepad++ then.

Yes. Opening the same file has the change in one window and the "old" version in another.

@roblourens
Copy link
Member

You can easily disable this with "files.hotExit": "off". From what I understand, notepad++ has this feature too.

It should only open one instance, with your change, though.

@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Feb 23, 2017
@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 23, 2017

Well my vote would be "files.hotExit" to default to "off".

Sorry I mispoke. I'm using Notepad2, not notepad++.

Notepad2 for me doesn't behave this way and I can't find how to make it behave that way. In fact every other editor I've ever used doesn't behave this way. I can't imagine anybody would find the "hotExit" option nor think to look for it.

@Tyriar
Copy link
Member

Tyriar commented Feb 23, 2017

The conservative hot exit option is enabled by default, you can disable it completely or enable it under more circumstances in settings. You can read more about why this decision was made here #101, basically this was the direction because this is similar to how Notepad++, Sublime Text and Atom behave and because it's easier to switch off if you're someone who is not a fan than realize it's supported and switch it on.

You would have also received a prompt when you first exited vscode with unsaved files saying that hot exit is now the default and how you can go about disabling it.

On multiple windows opening, this is likely because one window is being restored and the other is the window that you requested to open, for example if you opened a file/folder via explorer.

@Tyriar Tyriar closed this as completed Feb 23, 2017
@Tyriar Tyriar added *as-designed Described behavior is as designed and removed bug Issue identified by VS Code Team member as probable bug labels Feb 23, 2017
@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 23, 2017

So you're saying that not only is hotexit the default because people will complain about if it they don't like it, but also the other behavior is by design too.

I did this

  • Opened multiple files through Windows explorer
  • Edited some of them (over the course of an hour or so while I was also doing two other things at same time)
  • Closed VS Code not realizing I had not saved some of the edits. Figuring that if I hadn't, it would have prompted.
  • Ran some tests that depended upon said edits.
  • Spent half an hour trying to figure out why the tests weren't behaving
  • Reopened one of the files through Windows explorer

VS Code then opened two instances of that file because I happened to not have saved it.

I looked at the discussion for the hotexit https://github.com/Microsoft/vscode/issues/101 and found I agree with some of the points, but I'd still want it to prompt on exit.

Visual Studio handles this by remembering the files/tabs opened, and any unsaved files will prompted next time you open to be recovered. But it always asks when you close VS.

I don't like the idea of making edits and then I have to open VSCode again in order to get those edits back. In my situation I didn't even realize I hadn't saved the files.

I think what you should do is have an auto backup but still prompt on exit. Does this mean on reboot VS Code will not cause the machine to stop restart?

@Tyriar
Copy link
Member

Tyriar commented Feb 23, 2017

So you're saying that not only is hotexit the default because people will complain about if it they don't like it

I did not say that. For the small portion of users who don't like they can change the setting and this is a very small portion based on telemetry and tracking our feedback channels.

There's an easy fix to your preferred way of working and that's to disable the setting. We committed to the behavior change and provided a prompt to users the first time hot exit occurs that explains what it is and how to configure it. If you like Visual Studio's behavior then set "files.hotExit": "off", Visual Studio Code is not Visual Studio and the default behavior aligns with lighter weight editors that it's more similar to.

Backups are always happening regardless of whether hot exit is enabled in order to provide crash protection.

@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 23, 2017

I have a better suggestion. Always keep track of the undo stack (even on close) but always be saving my files so I never have to hit save again. Although that would essentially mean an infinite history. Perhaps an undo from close to close.

I like the way onenote just saves, I stop thinking about having to hit CTRL+S in one note. I wish onenote had the full history of a note though.

At least hotExit should keep the undo stack since the last save.

@Tyriar
Copy link
Member

Tyriar commented Feb 23, 2017

Adding undo stack support is captured in #15135

You might also be interested in enabling auto save, that way you don't have to worry about saving your files at all: "files.autoSave": "afterDelay"

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

3 participants