feat: poke user when supplying faulty configurations

This commit is contained in:
Lukas Wirth
2022-01-06 14:23:35 +01:00
parent 8887d2016f
commit dd20a6f701
4 changed files with 36 additions and 12 deletions

View File

@@ -9,6 +9,7 @@ use std::{
use always_assert::always;
use crossbeam_channel::{select, Receiver};
use ide_db::base_db::{SourceDatabaseExt, VfsPath};
use itertools::Itertools;
use lsp_server::{Connection, Notification, Request};
use lsp_types::notification::Notification as _;
use vfs::{ChangeKind, FileId};
@@ -731,7 +732,17 @@ impl GlobalState {
// Note that json can be null according to the spec if the client can't
// provide a configuration. This is handled in Config::update below.
let mut config = Config::clone(&*this.config);
config.update(json.take());
if let Err(errors) = config.update(json.take()) {
let errors = errors
.iter()
.format_with("\n", |(key, e),f| {
f(key)?;
f(&": ")?;
f(e)
});
let msg= format!("Failed to deserialize config key(s):\n{}", errors);
this.show_message(lsp_types::MessageType::WARNING, msg);
}
this.update_configuration(config);
}
}