@@ -9,10 +9,7 @@ use tui::text::{Span, Spans};
99use super::{align_view, push_jump, Align, Context, Editor};
1010
1111use helix_core::{path, Selection};
12−use helix_view::{
13− editor::Action,
14− theme::{Modifier, Style},
15−};
12+use helix_view::{editor::Action, theme::Style};
1613
1714use crate::{
1815 compositor::{self, Compositor},
@@ -99,9 +96,9 @@ struct PickerDiagnostic {
9996}
10097
10198impl ui::menu::Item for PickerDiagnostic {
102− type Data = DiagnosticStyles;
99+ type Data = (DiagnosticStyles, DiagnosticsFormat);
103100
104− fn label(&self, styles: &Self::Data) -> Spans {
101+ fn label(&self, (styles, format): &Self::Data) -> Spans {
105102 let mut style = self
106103 .diag
107104 .severity
@@ -128,13 +125,18 @@ impl ui::menu::Item for PickerDiagnostic {
128125 .map(|code| format!(" ({})", code))
129126 .unwrap_or_default();
130127
131− let truncated_path = path::get_truncated_path(self.url.path())
132− .to_string_lossy()
133− .into_owned();
128+ let path = match format {
129+ DiagnosticsFormat::HideSourcePath => String::new(),
130+ DiagnosticsFormat::ShowSourcePath => {
131+ let path = path::get_truncated_path(self.url.path())
132+ .to_string_lossy()
133+ .into_owned();
134+ format!("{}: ", path)
135+ }
136+ };
134137
135138 Spans::from(vec![
136− Span::raw(truncated_path),
137− Span::raw(": "),
139+ Span::raw(path),
138140 Span::styled(&self.diag.message, style),
139141 Span::styled(code, style),
140142 ])
@@ -237,10 +239,17 @@ fn sym_picker(
237239 .truncate_start(false)
238240}
239241
242+#[derive(Copy, Clone, PartialEq)]
243+enum DiagnosticsFormat {
244+ ShowSourcePath,
245+ HideSourcePath,
246+}
247+
240248fn diag_picker(
241249 cx: &Context,
242250 diagnostics: BTreeMap<lsp::Url, Vec<lsp::Diagnostic>>,
243251 current_path: Option<lsp::Url>,
252+ format: DiagnosticsFormat,
244253 offset_encoding: OffsetEncoding,
245254) -> FilePicker<PickerDiagnostic> {
246255 // TODO: drop current_path comparison and instead use workspace: bool flag?
@@ -266,7 +275,7 @@ fn diag_picker(
266275
267276 FilePicker::new(
268277 flat_diag,
269− styles,
278+ (styles, format),
270279 move |cx, PickerDiagnostic { url, diag }, action| {
271280 if current_path.as_ref() == Some(url) {
272281 let (view, doc) = current!(cx.editor);
@@ -378,6 +387,7 @@ pub fn diagnostics_picker(cx: &mut Context) {
378387 cx,
379388 [(current_url.clone(), diagnostics)].into(),
380389 Some(current_url),
390+ DiagnosticsFormat::HideSourcePath,
381391 offset_encoding,
382392 );
383393 cx.push_layer(Box::new(overlayed(picker)));
@@ -390,7 +400,13 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) {
390400 let current_url = doc.url();
391401 let offset_encoding = language_server.offset_encoding();
392402 let diagnostics = cx.editor.diagnostics.clone();
393− let picker = diag_picker(cx, diagnostics, current_url, offset_encoding);
403+ let picker = diag_picker(
404+ cx,
405+ diagnostics,
406+ current_url,
407+ DiagnosticsFormat::ShowSourcePath,
408+ offset_encoding,
409+ );
394410 cx.push_layer(Box::new(overlayed(picker)));
395411}
396412