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

workspace: fix untitled file-saving #12577

Merged

Conversation

vladarama
Copy link
Contributor

What it does

This PR fixes #12557 by fixing the untitled file saving behavior when closing the Workspace. The user should now be prompted to select a location to save the untitled file before closing the Workspace. The file should be saved at the chosen location, and the Workspace should reload successfully, preserving the newly created file.

How to test

  1. Remove AutoSave: File -> AutoSave
  2. Create new file from header: File -> New File or Alt+N
  3. Enter random content inside this new file which is unsaved
  4. Close the workspace: File -> Close Workspace
  5. The user should now be prompted with a dialog to save the untitled file
  6. Select Save and choose a location to save the file
  7. Reopen the Workspace and the newly created file should be saved successfully

Review checklist

Reminder for reviewers

@vince-fugnitto vince-fugnitto self-requested a review May 30, 2023 12:01
@vince-fugnitto vince-fugnitto added core issues related to the core of the application workspace issues related to the workspace labels May 30, 2023
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave the review offline but for transparency I'll include an update.

We should align the behavior when closing the application and there are unsaved changes with VS Code by:

  • prompting once for all unsaved changes (resources + untitled resources)
  • selecting save all from the dialog should save all resources, and should prompt to select a location for the untitled resources (similarly to save as...)
  • we should attempt to save the untitled resources in the current workspace by default (might be tricky since we do not know about workspaces in @theia/core)

This should fix the main user-experience issues present in the pull-request where we prompt for each untitled file whether we want to save or not. It also fixes the issue where if we dont save the untitled files we still show them later in the main "save all" dialog.

@JonasHelming
Copy link
Contributor

@vladarama Is this ready for a re-review?

@vladarama vladarama force-pushed the gh-12557-workspace-save-fixes branch from 4a95793 to 1ca2420 Compare August 22, 2023 14:53
This commit fixes the untitled file-saving issue by making sure that the
untitled files are saved correctly before closing the workspace /
closing the application.

Signed-off-by: Vlad Arama <[email protected]>
@vladarama vladarama force-pushed the gh-12557-workspace-save-fixes branch from 1ca2420 to 14fea31 Compare August 22, 2023 15:02
@vladarama
Copy link
Contributor Author

@JonasHelming
Yes, I revisited the PR today and made some minor code cleanup. Should be ready for another review.

This commit includes a refactoring of the `onWillStop()` method to
prevent the workspace from closing when we decide to cancel the file
saving dialog.

Signed-off-by: Vlad Arama <[email protected]>
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 I confirmed that the behavior for dirty untitled documents is fixed with the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core issues related to the core of the application workspace issues related to the workspace
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Bug: Closing workspace does not save a new file
3 participants