settings: Show error notification when settings are invalid (#15905)
https://github.com/user-attachments/assets/07627142-e730-4446-a50b-7ef46f8e661c We want to improve the design in the future, but it fixes a long standing paper cut for now. Release Notes: - Added a popup that is displayed when the settings are invalid --------- Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
94028290cc
commit
efbf7ada28
4 changed files with 42 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
|||
use crate::{settings_store::SettingsStore, Settings};
|
||||
use anyhow::Result;
|
||||
use fs::Fs;
|
||||
use futures::{channel::mpsc, StreamExt};
|
||||
use gpui::{AppContext, BackgroundExecutor, ReadGlobal, UpdateGlobal};
|
||||
|
@ -66,6 +67,7 @@ pub fn watch_config_file(
|
|||
pub fn handle_settings_file_changes(
|
||||
mut user_settings_file_rx: mpsc::UnboundedReceiver<String>,
|
||||
cx: &mut AppContext,
|
||||
settings_changed: impl Fn(Result<()>, &mut AppContext) + 'static,
|
||||
) {
|
||||
let user_settings_content = cx
|
||||
.background_executor()
|
||||
|
@ -79,9 +81,11 @@ pub fn handle_settings_file_changes(
|
|||
cx.spawn(move |mut cx| async move {
|
||||
while let Some(user_settings_content) = user_settings_file_rx.next().await {
|
||||
let result = cx.update_global(|store: &mut SettingsStore, 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, cx);
|
||||
cx.refresh();
|
||||
});
|
||||
if result.is_err() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue