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

Notebook shows dirty indicator with autosave on #140069

Closed
roblourens opened this issue Jan 4, 2022 · 5 comments · Fixed by #189345
Closed

Notebook shows dirty indicator with autosave on #140069

roblourens opened this issue Jan 4, 2022 · 5 comments · Fixed by #189345
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders notebook-workbench-integration verified Verification succeeded
Milestone

Comments

@roblourens
Copy link
Member

  • Set auto save: afterDelay
  • Edit a notebook
  • See the dirty indicator briefly appear after editing
@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug notebook-workbench-integration labels Jan 4, 2022
@roblourens roblourens added this to the Backlog milestone Jan 4, 2022
@roblourens
Copy link
Member Author

I guess this is #96400

@bpasero
Copy link
Member

bpasero commented Jan 4, 2022

We never did that for custom editors because it requires code to ensure that an editor that is closed but pending to be saved via auto save is really waited upon on shutdown. To further explain:

  • the behaviour is driven by EditorInput#isSaving method
  • if you return true from that method no dirty indicator will show up
  • this means a user can close an editor with dirty changes
  • as such, components have to ensure that the save continues in the background and even on shutdown

Files implement this here:

override isSaving(): boolean {
if (this.model?.hasState(TextFileEditorModelState.SAVED) || this.model?.hasState(TextFileEditorModelState.CONFLICT) || this.model?.hasState(TextFileEditorModelState.ERROR)) {
return false; // require the model to be dirty and not in conflict or error state
}
// Note: currently not checking for ModelState.PENDING_SAVE for a reason
// because we currently miss an event for this state change on editors
// and it could result in bad UX where an editor can be closed even though
// it shows up as dirty and has not finished saving yet.
if (this.filesConfigurationService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
return true; // a short auto save is configured, treat this as being saved
}
return super.isSaving();
}

I think the reason we never adopted this for notebooks as that notebooks have a dual model: complex and simple. With simple (which is based on file working copies), we can probably implement this now similar to what files do, but it needs careful testing what happens when you close a notebook quickly enough before auto save finished.

@rebornix
Copy link
Member

We could revisit this once we remove complex notebook model and friends #144810 but the saving of notebooks is more complex than files and I wonder if it's worth it to implement this. Also the dirty indicator is also an indicator that saving is not done yet, which is valuable as saving notebooks is not necessarily instant. what do you think @roblourens ?

@roblourens
Copy link
Member Author

I think it's ok to close if this is complicated. It's also a bit odd that if I edit and immediately close the tab, it asks me whether I want to save, when I've enabled autosave.

@bpasero
Copy link
Member

bpasero commented Jul 21, 2023

@amunger with your recent changes in #187304 and #187302 please take note of #140069 (comment).

Specifically: being able to close an editor that is now not dirty because of auto-save may result in data loss if closing the editor disposes state that is needed for saving.

Filed #188452 as planned for July.

Nevertheless, I appreciate that you are willing to look into this issue 🙏

@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 31, 2023
@rzhao271 rzhao271 modified the milestones: Backlog, August 2023 Aug 28, 2023
@joyceerhl joyceerhl added the verified Verification succeeded label Aug 31, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders notebook-workbench-integration verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants