on master help sign in
diagnostics: Use Vec<Tag> instead of Option<Vec<Tag>>
1df32c9Blaž Hrastnik
helix-core/src/diagnostic.rs+1−1
@@ -43,6 +43,6 @@ pub struct Diagnostic {
43 pub message: String,
43 pub message: String,
44 pub severity: Option<Severity>,
44 pub severity: Option<Severity>,
45 pub code: Option<NumberOrString>,
45 pub code: Option<NumberOrString>,
46− pub tags: Option<Vec<DiagnosticTag>>,
46+ pub tags: Vec<DiagnosticTag>,
47 pub source: Option<String>,
47 pub source: Option<String>,
48}
48}
helix-lsp/src/lib.rs+11−12
@@ -84,19 +84,18 @@ pub mod util {
84 None => None,
84 None => None,
85 };
85 };
86
86
87− let tags = if let Some(ref tags) = diag.tags {
87+ let new_tags: Vec<_> = diag
88− let new_tags = tags
88+ .tags
89− .iter()
89+ .iter()
90− .map(|tag| match tag {
90+ .map(|tag| match tag {
91− helix_core::diagnostic::DiagnosticTag::Unnecessary => {
91+ helix_core::diagnostic::DiagnosticTag::Unnecessary => {
92− lsp::DiagnosticTag::UNNECESSARY
92+ lsp::DiagnosticTag::UNNECESSARY
93− }
93+ }
94− helix_core::diagnostic::DiagnosticTag::Deprecated => {
94+ helix_core::diagnostic::DiagnosticTag::Deprecated => lsp::DiagnosticTag::DEPRECATED,
95− lsp::DiagnosticTag::DEPRECATED
96− }
97− })
95+ })
98− .collect();
96+ .collect();
99
97
98+ let tags = if !new_tags.is_empty() {
100 Some(new_tags)
99 Some(new_tags)
101 } else {
100 } else {
102 None
101 None
helix-term/src/application.rs+2−2
@@ -614,9 +614,9 @@ impl Application {
614 }
614 }
615 }).collect();
615 }).collect();
616
616
617− Some(new_tags)
617+ new_tags
618 } else {
618 } else {
619− None
619+ Vec::new()
620 };
620 };
621
621
622 Some(Diagnostic {
622 Some(Diagnostic {