Notify about broken task file contents (#27185)
Closes https://github.com/zed-industries/zed/issues/23783 https://github.com/user-attachments/assets/df019f68-a76b-4953-967a-a35ed21206ab Release Notes: - Added notifications when invalid tasks.json/debug.json is saved
This commit is contained in:
parent
de99febd9b
commit
aae81fd54c
7 changed files with 200 additions and 123 deletions
|
@ -5,7 +5,9 @@ use fs::Fs;
|
|||
use futures::{channel::mpsc, future::LocalBoxFuture, FutureExt, StreamExt};
|
||||
use gpui::{App, AsyncApp, BorrowAppContext, Global, Task, UpdateGlobal};
|
||||
|
||||
use paths::{local_settings_file_relative_path, EDITORCONFIG_NAME};
|
||||
use paths::{
|
||||
debug_task_file_name, local_settings_file_relative_path, task_file_name, EDITORCONFIG_NAME,
|
||||
};
|
||||
use schemars::{gen::SchemaGenerator, schema::RootSchema, JsonSchema};
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use smallvec::SmallVec;
|
||||
|
@ -250,6 +252,16 @@ trait AnySettingValue: 'static + Send + Sync {
|
|||
|
||||
struct DeserializedSetting(Box<dyn Any>);
|
||||
|
||||
impl TaskKind {
|
||||
/// Returns a file path of a task configuration file of this kind within the given directory.
|
||||
pub fn config_in_dir(&self, dir: &Path) -> PathBuf {
|
||||
dir.join(match self {
|
||||
Self::Debug => debug_task_file_name(),
|
||||
Self::Script => task_file_name(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl SettingsStore {
|
||||
pub fn new(cx: &App) -> Self {
|
||||
let (setting_file_updates_tx, mut setting_file_updates_rx) = mpsc::unbounded();
|
||||
|
@ -610,10 +622,11 @@ impl SettingsStore {
|
|||
.map(|content| content.trim())
|
||||
.filter(|content| !content.is_empty()),
|
||||
) {
|
||||
(LocalSettingsKind::Tasks(_), _) => {
|
||||
(LocalSettingsKind::Tasks(task_kind), _) => {
|
||||
return Err(InvalidSettingsError::Tasks {
|
||||
message: "Attempted to submit tasks into the settings store".to_string(),
|
||||
})
|
||||
path: task_kind.config_in_dir(&directory_path),
|
||||
});
|
||||
}
|
||||
(LocalSettingsKind::Settings, None) => {
|
||||
zed_settings_changed = self
|
||||
|
@ -1011,7 +1024,7 @@ pub enum InvalidSettingsError {
|
|||
ServerSettings { message: String },
|
||||
DefaultSettings { message: String },
|
||||
Editorconfig { path: PathBuf, message: String },
|
||||
Tasks { message: String },
|
||||
Tasks { path: PathBuf, message: String },
|
||||
}
|
||||
|
||||
impl std::fmt::Display for InvalidSettingsError {
|
||||
|
@ -1021,7 +1034,7 @@ impl std::fmt::Display for InvalidSettingsError {
|
|||
| InvalidSettingsError::UserSettings { message }
|
||||
| InvalidSettingsError::ServerSettings { message }
|
||||
| InvalidSettingsError::DefaultSettings { message }
|
||||
| InvalidSettingsError::Tasks { message }
|
||||
| InvalidSettingsError::Tasks { message, .. }
|
||||
| InvalidSettingsError::Editorconfig { message, .. } => {
|
||||
write!(f, "{message}")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue