on master help sign in
diagnostics: Use Vec<Tag> instead of Option<Vec<Tag>>
commit1df32c917c8a386947063403577098d1277380c7 authorBlaž Hrastnik <blaz@mxxn.io> dateTue 20 Sep 2022, 16:28 (4 years ago) parent64b0745
3 files changed+14−15
helix-core/src/diagnostic.rs+1−1 helix-lsp/src/lib.rs+11−12 helix-term/src/application.rs+2−2
helix-core/src/diagnostic.rs+1−1
@@ -43,6 +43,6 @@ pub struct Diagnostic {
4343 pub message: String,
4444 pub severity: Option<Severity>,
4545 pub code: Option<NumberOrString>,
46− pub tags: Option<Vec<DiagnosticTag>>,
46+ pub tags: Vec<DiagnosticTag>,
4747 pub source: Option<String>,
4848}
helix-lsp/src/lib.rs+11−12
@@ -84,19 +84,18 @@ pub mod util {
8484 None => None,
8585 };
8686
87− let tags = if let Some(ref tags) = diag.tags {
88− let new_tags = tags
89− .iter()
90− .map(|tag| match tag {
91− helix_core::diagnostic::DiagnosticTag::Unnecessary => {
92− lsp::DiagnosticTag::UNNECESSARY
93− }
94− helix_core::diagnostic::DiagnosticTag::Deprecated => {
95− lsp::DiagnosticTag::DEPRECATED
96− }
97− })
98− .collect();
87+ let new_tags: Vec<_> = diag
88+ .tags
89+ .iter()
90+ .map(|tag| match tag {
91+ helix_core::diagnostic::DiagnosticTag::Unnecessary => {
92+ lsp::DiagnosticTag::UNNECESSARY
93+ }
94+ helix_core::diagnostic::DiagnosticTag::Deprecated => lsp::DiagnosticTag::DEPRECATED,
95+ })
96+ .collect();
9997
98+ let tags = if !new_tags.is_empty() {
10099 Some(new_tags)
101100 } else {
102101 None
helix-term/src/application.rs+2−2
@@ -614,9 +614,9 @@ impl Application {
614614 }
615615 }).collect();
616616
617− Some(new_tags)
617+ new_tags
618618 } else {
619− None
619+ Vec::new()
620620 };
621621
622622 Some(Diagnostic {