Exclude gitignored files' diagnostics from project panel and its indicator.

The diagnostics are collected and available still, since that might become a settings/UI toggle later.
Also, buffer diagnostics are still updated for gitignored files.
This commit is contained in:
Kirill Bulatov 2023-11-30 15:38:54 +02:00
parent 7b76db4b50
commit 69bfd47cf9
5 changed files with 118 additions and 29 deletions

View file

@ -6533,9 +6533,15 @@ impl Project {
})
}
pub fn diagnostic_summary(&self, cx: &AppContext) -> DiagnosticSummary {
pub fn diagnostic_summary(&self, include_ignored: bool, cx: &AppContext) -> DiagnosticSummary {
let mut summary = DiagnosticSummary::default();
for (_, _, path_summary) in self.diagnostic_summaries(cx) {
for (_, _, path_summary) in
self.diagnostic_summaries(include_ignored, cx)
.filter(|(path, _, _)| {
let worktree = self.entry_for_path(&path, cx).map(|entry| entry.is_ignored);
include_ignored || worktree == Some(false)
})
{
summary.error_count += path_summary.error_count;
summary.warning_count += path_summary.warning_count;
}
@ -6544,6 +6550,7 @@ impl Project {
pub fn diagnostic_summaries<'a>(
&'a self,
include_ignored: bool,
cx: &'a AppContext,
) -> impl Iterator<Item = (ProjectPath, LanguageServerId, DiagnosticSummary)> + 'a {
self.visible_worktrees(cx).flat_map(move |worktree| {
@ -6554,6 +6561,10 @@ impl Project {
.map(move |(path, server_id, summary)| {
(ProjectPath { worktree_id, path }, server_id, summary)
})
.filter(move |(path, _, _)| {
let worktree = self.entry_for_path(&path, cx).map(|entry| entry.is_ignored);
include_ignored || worktree == Some(false)
})
})
}