on master help sign in
LSP: Separate diagnostic picker message and code (#6095)
d15f972Francesc Elies
helix-term/src/commands/lsp.rs+6−11
@@ -32,8 +32,7 @@ use crate::{
32};
32};
33
33
34use std::{
34use std::{
35− borrow::Cow, cmp::Ordering, collections::BTreeMap, fmt::Write, future::Future, path::PathBuf,
35+ cmp::Ordering, collections::BTreeMap, fmt::Write, future::Future, path::PathBuf, sync::Arc,
36− sync::Arc,
37};
36};
38
37
39/// Gets the language server that is attached to a document, and
38/// Gets the language server that is attached to a document, and
@@ -138,15 +137,11 @@ impl ui::menu::Item for PickerDiagnostic {
138 // remove background as it is distracting in the picker list
137 // remove background as it is distracting in the picker list
139 style.bg = None;
138 style.bg = None;
140
139
141− let code: Cow<'_, str> = self
140+ let code = match self.diag.code.as_ref() {
142− .diag
143− .code
144− .as_ref()
145− .map(|c| match c {
146− NumberOrString::Number(n) => n.to_string().into(),
141+ Some(NumberOrString::Number(n)) => format!(" ({n})"),
147− NumberOrString::String(s) => s.as_str().into(),
142+ Some(NumberOrString::String(s)) => format!(" ({s})"),
148− })
143+ None => String::new(),
149− .unwrap_or_default();
144+ };
150
145
151 let path = match format {
146 let path = match format {
152 DiagnosticsFormat::HideSourcePath => String::new(),
147 DiagnosticsFormat::HideSourcePath => String::new(),