mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-26 00:19:46 +00:00
Restructure inner path data
This commit is contained in:
parent
7145fabb6d
commit
ff1d692e46
1 changed files with 15 additions and 14 deletions
|
@ -3,7 +3,7 @@ mod project_diagnostics_settings;
|
||||||
mod toolbar_controls;
|
mod toolbar_controls;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use collections::{BTreeSet, HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use editor::{
|
use editor::{
|
||||||
diagnostic_block_renderer,
|
diagnostic_block_renderer,
|
||||||
display_map::{BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock},
|
display_map::{BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock},
|
||||||
|
@ -61,7 +61,7 @@ struct ProjectDiagnosticsEditor {
|
||||||
summary: DiagnosticSummary,
|
summary: DiagnosticSummary,
|
||||||
excerpts: ModelHandle<MultiBuffer>,
|
excerpts: ModelHandle<MultiBuffer>,
|
||||||
path_states: Vec<PathState>,
|
path_states: Vec<PathState>,
|
||||||
paths_to_update: BTreeSet<(ProjectPath, LanguageServerId)>,
|
paths_to_update: HashMap<LanguageServerId, HashSet<ProjectPath>>,
|
||||||
current_diagnostics: HashMap<LanguageServerId, HashSet<ProjectPath>>,
|
current_diagnostics: HashMap<LanguageServerId, HashSet<ProjectPath>>,
|
||||||
include_warnings: bool,
|
include_warnings: bool,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
|
@ -128,9 +128,12 @@ impl View for ProjectDiagnosticsEditor {
|
||||||
"summary": project.diagnostic_summary(cx),
|
"summary": project.diagnostic_summary(cx),
|
||||||
}),
|
}),
|
||||||
"summary": self.summary,
|
"summary": self.summary,
|
||||||
"paths_to_update": self.paths_to_update.iter().map(|(path, server_id)|
|
"paths_to_update": self.paths_to_update.iter().map(|(server_id, paths)|
|
||||||
(path.path.to_string_lossy(), server_id.0)
|
(server_id.0, paths.into_iter().map(|path| path.path.to_string_lossy()).collect::<Vec<_>>())
|
||||||
).collect::<Vec<_>>(),
|
).collect::<HashMap<_, _>>(),
|
||||||
|
"current_diagnostics": self.current_diagnostics.iter().map(|(server_id, paths)|
|
||||||
|
(server_id.0, paths.into_iter().map(|path| path.path.to_string_lossy()).collect::<Vec<_>>())
|
||||||
|
).collect::<HashMap<_, _>>(),
|
||||||
"paths_states": self.path_states.iter().map(|state|
|
"paths_states": self.path_states.iter().map(|state|
|
||||||
json!({
|
json!({
|
||||||
"path": state.path.path.to_string_lossy(),
|
"path": state.path.path.to_string_lossy(),
|
||||||
|
@ -164,7 +167,9 @@ impl ProjectDiagnosticsEditor {
|
||||||
} => {
|
} => {
|
||||||
log::debug!("Adding path {path:?} to update for server {language_server_id}");
|
log::debug!("Adding path {path:?} to update for server {language_server_id}");
|
||||||
this.paths_to_update
|
this.paths_to_update
|
||||||
.insert((path.clone(), *language_server_id));
|
.entry(*language_server_id)
|
||||||
|
.or_default()
|
||||||
|
.insert(path.clone());
|
||||||
let no_multiselections = this.editor.update(cx, |editor, cx| {
|
let no_multiselections = this.editor.update(cx, |editor, cx| {
|
||||||
editor.selections.all::<usize>(cx).len() <= 1
|
editor.selections.all::<usize>(cx).len() <= 1
|
||||||
});
|
});
|
||||||
|
@ -198,7 +203,7 @@ impl ProjectDiagnosticsEditor {
|
||||||
excerpts,
|
excerpts,
|
||||||
editor,
|
editor,
|
||||||
path_states: Default::default(),
|
path_states: Default::default(),
|
||||||
paths_to_update: BTreeSet::new(),
|
paths_to_update: HashMap::default(),
|
||||||
include_warnings: settings::get::<ProjectDiagnosticsSettings>(cx).include_warnings,
|
include_warnings: settings::get::<ProjectDiagnosticsSettings>(cx).include_warnings,
|
||||||
current_diagnostics: HashMap::default(),
|
current_diagnostics: HashMap::default(),
|
||||||
_subscriptions: vec![project_event_subscription, editor_event_subscription],
|
_subscriptions: vec![project_event_subscription, editor_event_subscription],
|
||||||
|
@ -245,20 +250,16 @@ impl ProjectDiagnosticsEditor {
|
||||||
if let Some(language_server_id) = language_server_id {
|
if let Some(language_server_id) = language_server_id {
|
||||||
new_summaries.retain(|server_id, _| server_id == &language_server_id);
|
new_summaries.retain(|server_id, _| server_id == &language_server_id);
|
||||||
old_diagnostics.retain(|server_id, _| server_id == &language_server_id);
|
old_diagnostics.retain(|server_id, _| server_id == &language_server_id);
|
||||||
self.paths_to_update.retain(|(path, server_id)| {
|
self.paths_to_update.retain(|server_id, paths| {
|
||||||
if server_id == &language_server_id {
|
if server_id == &language_server_id {
|
||||||
paths_to_recheck.insert(path.clone());
|
paths_to_recheck.extend(paths.drain());
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
paths_to_recheck.extend(
|
paths_to_recheck.extend(self.paths_to_update.drain().flat_map(|(_, paths)| paths));
|
||||||
mem::replace(&mut self.paths_to_update, BTreeSet::new())
|
|
||||||
.into_iter()
|
|
||||||
.map(|(path, _)| path),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (server_id, new_paths) in new_summaries {
|
for (server_id, new_paths) in new_summaries {
|
||||||
|
|
Loading…
Reference in a new issue