Display a warning if SUI is unable to write to settings file #19027
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Adds logic to display a warning popup if the settings.json is marked as read-only and we try to write to the settings.json file. Previously, this scenario would crash, which definitely isn't right. However, a simple fix of "not-crashing" wouldn't feel right either.
This leverages the existing infrastructure to display a warning dialog when we failed to write to the settings file. The main annoyance here is that that popup dialog is located in
TerminalWindow
and is normally triggered from a failedSettingsLoadEventArgs
. To get around this,CascadiaSettings::WriteSettingsToDisk()
now returns a boolean to signal if the write was successful; whereas if it fails, a warning is added to the settings object. If we fail to write to disk, the function will return false and we'll raise an event with the settings' warnings toTerminalPage
which passes it along toTerminalWindow
.Additionally, this uses
IVectorView<SettingsLoadWarnings>
as opposed toIVector<SettingsLoadWarnings>
throughout the relevant code. It's more correct as the list of warnings shouldn't be mutable and the warnings from theCascadiaSettings
object are retrieved in that format.Validation Steps Performed
Closes #18913