Skip to content

Commit 1df32c9

Browse files
committed
diagnostics: Use Vec<Tag> instead of Option<Vec<Tag>>
1 parent 64b0745 commit 1df32c9

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

helix-core/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

0 commit comments

Comments
 (0)