-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: Cannot quit app when there is a dirty editor (#13164) #13173
fix: Cannot quit app when there is a dirty editor (#13164) #13173
Conversation
1482909
to
2b8ed54
Compare
The actual bug was the "cancel for the save untitled editor file location picker"-behavior was incorrectly triggered by "don't save" button as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @emilhammarstedtst. The code appears to work fine, but I have a couple of suggestions.
packages/core/src/browser/dialogs.ts
Outdated
// Asks the user to confirm whether they want to exit with or without saving the changes | ||
export async function confirmExitWithOrWithoutSaving(captionsToSave: string[], performSave: () => Promise<void>): Promise<boolean> { | ||
export async function confirmExitWithOrWithoutSaving(captionsToSave: string[], performSave?: () => Promise<void>): Promise<confirmExitWithOrWithoutSavingResult> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would the parameter be optional? There is one usage in Theia code and it does pass something. If saving is a no-op, the user can always pass in a no-op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
packages/core/src/browser/dialogs.ts
Outdated
@@ -458,11 +458,18 @@ export class ConfirmSaveDialog extends AbstractDialog<boolean | undefined> { | |||
|
|||
} | |||
|
|||
export enum confirmExitWithOrWithoutSavingResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention is to return undefined from dialogs when the user does not make a choice (aka "the close box"). I don't think we should introduce a new type here, But just use boolean | undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the return type.
packages/core/src/browser/dialogs.ts
Outdated
@@ -458,11 +458,18 @@ export class ConfirmSaveDialog extends AbstractDialog<boolean | undefined> { | |||
|
|||
} | |||
|
|||
export enum confirmExitWithOrWithoutSavingResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should not move this method over to common-frontend-contribution.ts
. It only seems to be invoked from there and it seems to me we could simplify the code if we did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved it. seems logical and collected.
Contributed by STMicroelectronics Signed-off-by: Emil HAMMARSTEDT <[email protected]>
2b8ed54
to
e900e2f
Compare
What it does
fixes issue #13164, TheiaBlueprint 1.44.0 cannot quit app when there is a dirty editor
How to test
=> the app quits.
Review checklist
Reminder for reviewers
Contributed by STMicroelectronics