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

close without saving #1470

Open
snden opened this issue Jul 7, 2023 · 5 comments
Open

close without saving #1470

snden opened this issue Jul 7, 2023 · 5 comments
Labels
enhancement Request: New feature or improvement planned Note: Feature planned for a later release project management Component: Project or Project Tree

Comments

@snden
Copy link

snden commented Jul 7, 2023

Sometimes I need to close Novelwriter without saving the changes to disk. But the exit dialog allows to just stay in the project or close Novelwriter and save the project. Is it possible to give option to quit Novelwriter without saving?

@snden snden added the enhancement Request: New feature or improvement label Jul 7, 2023
@vkbo vkbo added the duplicate Invalid: This issue or pull request already exists label Jul 7, 2023
@vkbo
Copy link
Owner

vkbo commented Jul 7, 2023

This is a duplicate of #533, so I will close it. But I'll elaborate anyway.

The changes are already saved to disk, which is part of the core functionality of novelWriter. It treats your project as individual documents, so each time you edit a document, it is saved. I made a deliberate choice against keeping a project entirely in memory between saves. This is a specifically designed feature, but the disadvantage is that you cannot treat the project as if it was a single document (like in LibreOffice) and choose to not save it.

When I add the single project file option, it would be possible to discard changes, as there will be a distinction between the copy you're editing and the copy saved in your storage area (you cannot perform dynamic read/write operations on a zip file). I can possibly add a discard changes option when I implement this. See feature #977.

@vkbo vkbo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2023
@vkbo vkbo mentioned this issue Jul 7, 2023
9 tasks
@snden
Copy link
Author

snden commented Jul 7, 2023

Sorry for duplicating the topic.
Thanks for the explanation, the benefits of this system are obvious.

Of course, the decision is up to you. Anyway, let me offer a solution. If you are considering using the .zip format, it would be possible to create a temporary .zip copy of the project every time the user opens it, and use that when selecting Close without saving. And to update this backup copy only when saving manually while working, not when saving automatically. Once the project was closed, the temporary copy would be deleted.

@vkbo
Copy link
Owner

vkbo commented Jul 7, 2023

Sorry for duplicating the topic. Thanks for the explanation, the benefits of this system are obvious.

No problem. I've referenced this request in the single file format implementation so the specifics discussed here can be taken into account still.

Of course, the decision is up to you. Anyway, let me offer a solution. If you are considering using the .zip format, it would be possible to create a temporary .zip copy of the project every time the user opens it, and use that when selecting Close without saving. And to update this backup copy only when saving manually while working, not when saving automatically. Once the project was closed, the temporary copy would be deleted.

So, the thing about zip files is that they are archives. They are sort of multi-read, single-write. I say sort of, because you can append to them. However, you cannot practically use them for repeated writing. The way to work with them as storage for project or large document data (as LibreOffice and I think also MS Office does) is generally to extract them and keep them all in memory.

Since I want to preserve the continuous writing feature of novelWriter, which is a safety feature, I will extract the zip file when a project is opened. Then novelWriter will work against the extracted copy, and only create zip archives when the project is either manually saved (Ctrl+Shift+S) or when it is closed. The runtime vs stored location functionality, and the writing of the zip archive is already written into the current version of novelWriter. The former feature is not yet in use, and the latter is only currently used for backups.

Now, I haven't decided where to extract the archive. I want to either extract it to a temporary folder somewhere in the user's app directory (this is where novelWriter already stores other user-specific data), or I can extract the zip archive in the same location where the zip file is saved. I.e. If you open myproject.nwx a folder named for instance .myproject.tmp will be created. When a project is opened, and this folder exists, you will be offered the option to continue last unsaved session or discard it. The benefit of the in-place option is that it will also pass through file sync. I've seen other applications do exactly this, so it's a fairly neat solution. I may let the user choose between the two in some advanced settings tab.

In theory, I can also offer this solution for users using the folder based storage, as duplicating a folder isn't practically any different than extracting an archive. However, people who want to stay with the folder based projects will likely do so because they are already using a version control system, so they already have full control of the version history, and can easily just undo the changes they want to get rid of.

@vkbo
Copy link
Owner

vkbo commented Jul 7, 2023

You know what? The discussion here, and my own mind dump, is more up to date and in line with the current direction of where novelWriter is going, so I will reopen this and keep it as a feature linked to #533 and #977.

@vkbo vkbo reopened this Jul 7, 2023
@vkbo vkbo added project management Component: Project or Project Tree planned Note: Feature planned for a later release and removed duplicate Invalid: This issue or pull request already exists labels Jul 7, 2023
@vkbo vkbo added this to the Future Release milestone Jul 7, 2023
@awqk
Copy link

awqk commented May 22, 2024

It might help (at least it helps me) to think about this not as "close without saving", but as "revert to previous version", the previous version being the last one saved manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request: New feature or improvement planned Note: Feature planned for a later release project management Component: Project or Project Tree
Projects
None yet
Development

No branches or pull requests

3 participants