@@ -9,10 +9,7 @@ use tui::text::{Span, Spans};
9use super::{align_view, push_jump, Align, Context, Editor};
9use super::{align_view, push_jump, Align, Context, Editor};
11use helix_core::{path, Selection};
11use helix_core::{path, Selection};
12−use helix_view::{
12+use helix_view::{editor::Action, theme::Style};
14− theme::{Modifier, Style},
17use crate::{
14use crate::{
18 compositor::{self, Compositor},
15 compositor::{self, Compositor},
@@ -99,9 +96,9 @@ struct PickerDiagnostic {
101impl ui::menu::Item for PickerDiagnostic {
98impl ui::menu::Item for PickerDiagnostic {
102− type Data = DiagnosticStyles;
99+ type Data = (DiagnosticStyles, DiagnosticsFormat);
104− fn label(&self, styles: &Self::Data) -> Spans {
101+ fn label(&self, (styles, format): &Self::Data) -> Spans {
105 let mut style = self
102 let mut style = self
107 .severity
104 .severity
@@ -128,13 +125,18 @@ impl ui::menu::Item for PickerDiagnostic {
128 .map(|code| format!(" ({})", code))
125 .map(|code| format!(" ({})", code))
129 .unwrap_or_default();
126 .unwrap_or_default();
128+ let path = match format {
129+ DiagnosticsFormat::HideSourcePath => String::new(),
130+ DiagnosticsFormat::ShowSourcePath => {
131− let truncated_path = path::get_truncated_path(self.url.path())
131+ let path = path::get_truncated_path(self.url.path())
132− .to_string_lossy()
132+ .to_string_lossy()
133− .into_owned();
133+ .into_owned();
134+ format!("{}: ", path)
135 Spans::from(vec![
138 Spans::from(vec![
136− Span::raw(truncated_path),
139+ Span::raw(path),
138 Span::styled(&self.diag.message, style),
140 Span::styled(&self.diag.message, style),
139 Span::styled(code, style),
141 Span::styled(code, style),
@@ -237,10 +239,17 @@ fn sym_picker(
237 .truncate_start(false)
239 .truncate_start(false)
242+#[derive(Copy, Clone, PartialEq)]
243+enum DiagnosticsFormat {
240fn diag_picker(
248fn diag_picker(
241 cx: &Context,
249 cx: &Context,
242 diagnostics: BTreeMap<lsp::Url, Vec<lsp::Diagnostic>>,
250 diagnostics: BTreeMap<lsp::Url, Vec<lsp::Diagnostic>>,
243 current_path: Option<lsp::Url>,
251 current_path: Option<lsp::Url>,
252+ format: DiagnosticsFormat,
244 offset_encoding: OffsetEncoding,
253 offset_encoding: OffsetEncoding,
245) -> FilePicker<PickerDiagnostic> {
254) -> FilePicker<PickerDiagnostic> {
246 // TODO: drop current_path comparison and instead use workspace: bool flag?
255 // TODO: drop current_path comparison and instead use workspace: bool flag?
@@ -266,7 +275,7 @@ fn diag_picker(
267 FilePicker::new(
276 FilePicker::new(
268 flat_diag,
277 flat_diag,
269− styles,
278+ (styles, format),
270 move |cx, PickerDiagnostic { url, diag }, action| {
279 move |cx, PickerDiagnostic { url, diag }, action| {
271 if current_path.as_ref() == Some(url) {
280 if current_path.as_ref() == Some(url) {
272 let (view, doc) = current!(cx.editor);
281 let (view, doc) = current!(cx.editor);
@@ -378,6 +387,7 @@ pub fn diagnostics_picker(cx: &mut Context) {
379 [(current_url.clone(), diagnostics)].into(),
388 [(current_url.clone(), diagnostics)].into(),
380 Some(current_url),
389 Some(current_url),
390+ DiagnosticsFormat::HideSourcePath,
381 offset_encoding,
391 offset_encoding,
383 cx.push_layer(Box::new(overlayed(picker)));
393 cx.push_layer(Box::new(overlayed(picker)));
@@ -390,7 +400,13 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) {
390 let current_url = doc.url();
400 let current_url = doc.url();
391 let offset_encoding = language_server.offset_encoding();
401 let offset_encoding = language_server.offset_encoding();
392 let diagnostics = cx.editor.diagnostics.clone();
402 let diagnostics = cx.editor.diagnostics.clone();
393− let picker = diag_picker(cx, diagnostics, current_url, offset_encoding);
403+ let picker = diag_picker(
407+ DiagnosticsFormat::ShowSourcePath,
394 cx.push_layer(Box::new(overlayed(picker)));
410 cx.push_layer(Box::new(overlayed(picker)));