Show settings file errors on startup (#23817)

Required using a global `LazyLock<Mutex<AppNotifications>>` instead of a
context global because settings errors first occur before initialization
of the notifications global.

Release Notes:

- Errors in settings file are now reported in UI on startup.
This commit is contained in:
Michael Sloan 2025-01-29 00:05:33 -07:00 committed by GitHub
parent 06936c69f6
commit dbdf140ca1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 74 additions and 89 deletions

View file

@ -3,7 +3,6 @@ use fs::Fs;
use futures::{channel::mpsc, StreamExt};
use gpui::{App, BackgroundExecutor, ReadGlobal, UpdateGlobal};
use std::{path::PathBuf, sync::Arc, time::Duration};
use util::ResultExt;
pub const EMPTY_THEME_NAME: &str = "empty-theme";
@ -73,9 +72,11 @@ pub fn handle_settings_file_changes(
.block(user_settings_file_rx.next())
.unwrap();
SettingsStore::update_global(cx, |store, cx| {
store
.set_user_settings(&user_settings_content, cx)
.log_err();
let result = store.set_user_settings(&user_settings_content, cx);
if let Err(err) = &result {
log::error!("Failed to load user settings: {err}");
}
settings_changed(result.err(), cx);
});
cx.spawn(move |cx| async move {
while let Some(user_settings_content) = user_settings_file_rx.next().await {