Replace confirmCloseAllTabs with confirmOnClose#20055
Replace confirmCloseAllTabs with confirmOnClose#20055carlos-zamora wants to merge 1 commit intomainfrom
confirmCloseAllTabs with confirmOnClose#20055Conversation
|
Apologies if this is not the proper place for this question: is it possible to implement a fourth setting that would mean "present a warning dialog when closing multiple tabs/panes at once AND at least one background tab is in Running State"? |
|
Feedback from bug bash (4/7):
|
|
Note to self: also figure out #20083 (sorry for the back and forth Hlsg!) |
lhecker
left a comment
There was a problem hiding this comment.
Found 1 2? bugs, otherwise LGTM.
| }, | ||
| "warning.confirmCloseAllTabs": { | ||
| "deprecated": true, | ||
| "description": "[Deprecated] Use \"warning.confirmOnClose\" instead.", |
There was a problem hiding this comment.
We should add a "deprecated": true, property here: https://json-schema.org/understanding-json-schema/reference/annotations
| _RemoveTabs(tabsToRemove); | ||
|
|
||
| actionArgs.Handled(true); | ||
| actionArgs.Handled(!tabsToRemove.empty()); |
There was a problem hiding this comment.
Is this just a change on technical correctness or is there a common situation where tabsToRemove ends up being empty?
| dialog.Title(winrt::box_value(RS_(L"ConfirmCloseDialog_PaneTitle"))); | ||
| dialog.PrimaryButtonText(RS_(L"ConfirmCloseDialog_PanePrimary")); |
There was a problem hiding this comment.
It may be worth considering to add two local variables here and assign them in the switch/case. Then call Title/PrimaryButtonText only after the switch/case. This may make stepping under a debugger easier and the code (maybe?) ever so slightly easier to read. The box_value call can then also be abstracted away.
| _settings.GlobalSettings().ConfirmOnClose(ConfirmOnClose::Never); | ||
| _settings.WriteSettingsToDisk(); |
There was a problem hiding this comment.
No one's holding onto this here, right? Does ShowDialog block until after it has been dismissed? If so, the weak/strong dance may be worth it.
| { | ||
| return true; | ||
| } | ||
| return false; |
There was a problem hiding this comment.
You could express the above as a single return a || b if you wanted to. (The switch/case is fine IMO.)
| // so use the tab dialog text instead. | ||
| const auto kind = activeTab->GetLeafPaneCount() == 1 ? ConfirmCloseDialogKind::Tab : ConfirmCloseDialogKind::Pane; | ||
| auto warningResult = co_await _ShowConfirmCloseDialog(kind); | ||
| if (!weak.get() || warningResult != ContentDialogResult::Primary) |
There was a problem hiding this comment.
You're immediately dropping the strong reference here and you may be the last holder of this. If you search for !weak.get() in this branch it will come up a few more times.



Summary of the Pull Request
Replaces the
warning.confirmCloseAllTabssetting with awarning.confirmOnCloseenum setting that accepts the following:never: don't present a warning dialog when closing a sessionautomatic: present a warning dialog when closing multiple tabs/panes at oncealways: present a warning dialog when closing any sessionThe confirmation dialog contains a "don't ask me again" checkbox. When checked, we update the setting to
never.This setting also affects the following actions:
The appropriate confirmation dialog is shown in these scenarios. We also present an aggregate dialog instead of prompting the user once per tab/pane. If there are no other tabs/panes, we don't present a dialog and treat the key binding as unhandled (passing the key through).
References and Relevant Issues
Iteration of #19944
Validation Steps Performed
PR Checklist
Closes #5301
Closes #6641
"don't ask me again" checkbox is also mentioned in #10000
Co-authored by @zadjii-msft