Start diagnostic group_id at 1 to handle non LS diagnostics (#22694)
In particular, `DiagnosticPopover` both: * Supports moving the selection to a diagnostic when clicked, based on `group_id` * Provides Diagnostic values with `group_id: 0` providing informztion on hover about invisible characters. So, clicking such a popover would navigate to the very first error produced by a language server. Really not a big deal of course, but seems good to fix as it might result in surprising behavior in other future circumstances Release Notes: - N/A
This commit is contained in:
parent
7506c0385b
commit
3ae6aa0e4d
5 changed files with 74 additions and 74 deletions
|
@ -4065,7 +4065,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
DiagnosticEntry {
|
DiagnosticEntry {
|
||||||
range: Point::new(0, 4)..Point::new(0, 7),
|
range: Point::new(0, 4)..Point::new(0, 7),
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
group_id: 2,
|
group_id: 3,
|
||||||
message: "message 1".to_string(),
|
message: "message 1".to_string(),
|
||||||
severity: lsp::DiagnosticSeverity::ERROR,
|
severity: lsp::DiagnosticSeverity::ERROR,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
|
@ -4075,7 +4075,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
DiagnosticEntry {
|
DiagnosticEntry {
|
||||||
range: Point::new(0, 10)..Point::new(0, 13),
|
range: Point::new(0, 10)..Point::new(0, 13),
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
group_id: 3,
|
group_id: 4,
|
||||||
severity: lsp::DiagnosticSeverity::WARNING,
|
severity: lsp::DiagnosticSeverity::WARNING,
|
||||||
message: "message 2".to_string(),
|
message: "message 2".to_string(),
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
|
|
|
@ -82,7 +82,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::INFORMATION,
|
severity: DiagnosticSeverity::INFORMATION,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -95,7 +95,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::INFORMATION,
|
severity: DiagnosticSeverity::INFORMATION,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -106,7 +106,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::INFORMATION,
|
severity: DiagnosticSeverity::INFORMATION,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -117,7 +117,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::INFORMATION,
|
severity: DiagnosticSeverity::INFORMATION,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -128,7 +128,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -139,7 +139,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -241,7 +241,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
@ -348,7 +348,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -359,7 +359,7 @@ async fn test_diagnostics(cx: &mut TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -775,7 +775,7 @@ async fn test_random_diagnostics(cx: &mut TestAppContext, mut rng: StdRng) {
|
||||||
assert!(view.focus_handle.is_focused(cx));
|
assert!(view.focus_handle.is_focused(cx));
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut next_group_id = 0;
|
let mut next_group_id = 1;
|
||||||
let mut next_filename = 0;
|
let mut next_filename = 0;
|
||||||
let mut language_server_ids = vec![LanguageServerId(0)];
|
let mut language_server_ids = vec![LanguageServerId(0)];
|
||||||
let mut updated_language_servers = HashSet::default();
|
let mut updated_language_servers = HashSet::default();
|
||||||
|
|
|
@ -208,10 +208,10 @@ pub struct Diagnostic {
|
||||||
/// The human-readable message associated with this diagnostic.
|
/// The human-readable message associated with this diagnostic.
|
||||||
pub message: String,
|
pub message: String,
|
||||||
/// An id that identifies the group to which this diagnostic belongs.
|
/// An id that identifies the group to which this diagnostic belongs.
|
||||||
|
/// 0 is used for diagnostics that do not come from a language server.
|
||||||
///
|
///
|
||||||
/// When a language server produces a diagnostic with
|
/// When a language server produces a diagnostic with one or more associated diagnostics, those
|
||||||
/// one or more associated diagnostics, those diagnostics are all
|
/// diagnostics are all assigned a single group ID.
|
||||||
/// assigned a single group ID.
|
|
||||||
pub group_id: usize,
|
pub group_id: usize,
|
||||||
/// Whether this diagnostic is the primary diagnostic for its group.
|
/// Whether this diagnostic is the primary diagnostic for its group.
|
||||||
///
|
///
|
||||||
|
|
|
@ -2960,7 +2960,7 @@ impl LspStore {
|
||||||
http_client,
|
http_client,
|
||||||
fs,
|
fs,
|
||||||
yarn,
|
yarn,
|
||||||
next_diagnostic_group_id: Default::default(),
|
next_diagnostic_group_id: 1,
|
||||||
diagnostics: Default::default(),
|
diagnostics: Default::default(),
|
||||||
_subscription: cx.on_app_quit(|this, cx| {
|
_subscription: cx.on_app_quit(|this, cx| {
|
||||||
this.as_local_mut().unwrap().shutdown_language_servers(cx)
|
this.as_local_mut().unwrap().shutdown_language_servers(cx)
|
||||||
|
|
|
@ -1312,7 +1312,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
severity: lsp::DiagnosticSeverity::ERROR,
|
severity: lsp::DiagnosticSeverity::ERROR,
|
||||||
message: "undefined variable 'A'".to_string(),
|
message: "undefined variable 'A'".to_string(),
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -1828,7 +1828,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
message: "undefined variable 'BB'".to_string(),
|
message: "undefined variable 'BB'".to_string(),
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
@ -1840,7 +1840,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
message: "undefined variable 'CCC'".to_string(),
|
message: "undefined variable 'CCC'".to_string(),
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 2,
|
group_id: 3,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -1906,7 +1906,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
severity: DiagnosticSeverity::WARNING,
|
severity: DiagnosticSeverity::WARNING,
|
||||||
message: "unreachable statement".to_string(),
|
message: "unreachable statement".to_string(),
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 4,
|
group_id: 5,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -1918,7 +1918,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
message: "undefined variable 'A'".to_string(),
|
message: "undefined variable 'A'".to_string(),
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 3,
|
group_id: 4,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
@ -1998,7 +1998,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
severity: DiagnosticSeverity::WARNING,
|
severity: DiagnosticSeverity::WARNING,
|
||||||
message: "undefined variable 'A'".to_string(),
|
message: "undefined variable 'A'".to_string(),
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 6,
|
group_id: 7,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -2010,7 +2010,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
message: "undefined variable 'BB'".to_string(),
|
message: "undefined variable 'BB'".to_string(),
|
||||||
is_disk_based: true,
|
is_disk_based: true,
|
||||||
group_id: 5,
|
group_id: 6,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
@ -3838,7 +3838,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
severity: DiagnosticSeverity::WARNING,
|
severity: DiagnosticSeverity::WARNING,
|
||||||
message: "error 1".to_string(),
|
message: "error 1".to_string(),
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -3848,27 +3848,27 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
severity: DiagnosticSeverity::HINT,
|
severity: DiagnosticSeverity::HINT,
|
||||||
message: "error 1 hint 1".to_string(),
|
message: "error 1 hint 1".to_string(),
|
||||||
|
group_id: 2,
|
||||||
|
is_primary: false,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DiagnosticEntry {
|
||||||
|
range: Point::new(1, 13)..Point::new(1, 15),
|
||||||
|
diagnostic: Diagnostic {
|
||||||
|
severity: DiagnosticSeverity::HINT,
|
||||||
|
message: "error 2 hint 1".to_string(),
|
||||||
group_id: 1,
|
group_id: 1,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DiagnosticEntry {
|
|
||||||
range: Point::new(1, 13)..Point::new(1, 15),
|
|
||||||
diagnostic: Diagnostic {
|
|
||||||
severity: DiagnosticSeverity::HINT,
|
|
||||||
message: "error 2 hint 1".to_string(),
|
|
||||||
group_id: 0,
|
|
||||||
is_primary: false,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DiagnosticEntry {
|
DiagnosticEntry {
|
||||||
range: Point::new(1, 13)..Point::new(1, 15),
|
range: Point::new(1, 13)..Point::new(1, 15),
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
severity: DiagnosticSeverity::HINT,
|
severity: DiagnosticSeverity::HINT,
|
||||||
message: "error 2 hint 2".to_string(),
|
message: "error 2 hint 2".to_string(),
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -3878,43 +3878,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
message: "error 2".to_string(),
|
message: "error 2".to_string(),
|
||||||
group_id: 0,
|
group_id: 1,
|
||||||
is_primary: true,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
buffer.diagnostic_group::<Point>(0).collect::<Vec<_>>(),
|
|
||||||
&[
|
|
||||||
DiagnosticEntry {
|
|
||||||
range: Point::new(1, 13)..Point::new(1, 15),
|
|
||||||
diagnostic: Diagnostic {
|
|
||||||
severity: DiagnosticSeverity::HINT,
|
|
||||||
message: "error 2 hint 1".to_string(),
|
|
||||||
group_id: 0,
|
|
||||||
is_primary: false,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DiagnosticEntry {
|
|
||||||
range: Point::new(1, 13)..Point::new(1, 15),
|
|
||||||
diagnostic: Diagnostic {
|
|
||||||
severity: DiagnosticSeverity::HINT,
|
|
||||||
message: "error 2 hint 2".to_string(),
|
|
||||||
group_id: 0,
|
|
||||||
is_primary: false,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DiagnosticEntry {
|
|
||||||
range: Point::new(2, 8)..Point::new(2, 17),
|
|
||||||
diagnostic: Diagnostic {
|
|
||||||
severity: DiagnosticSeverity::ERROR,
|
|
||||||
message: "error 2".to_string(),
|
|
||||||
group_id: 0,
|
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -3924,13 +3888,49 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
buffer.diagnostic_group::<Point>(1).collect::<Vec<_>>(),
|
buffer.diagnostic_group::<Point>(1).collect::<Vec<_>>(),
|
||||||
|
&[
|
||||||
|
DiagnosticEntry {
|
||||||
|
range: Point::new(1, 13)..Point::new(1, 15),
|
||||||
|
diagnostic: Diagnostic {
|
||||||
|
severity: DiagnosticSeverity::HINT,
|
||||||
|
message: "error 2 hint 1".to_string(),
|
||||||
|
group_id: 1,
|
||||||
|
is_primary: false,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DiagnosticEntry {
|
||||||
|
range: Point::new(1, 13)..Point::new(1, 15),
|
||||||
|
diagnostic: Diagnostic {
|
||||||
|
severity: DiagnosticSeverity::HINT,
|
||||||
|
message: "error 2 hint 2".to_string(),
|
||||||
|
group_id: 1,
|
||||||
|
is_primary: false,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DiagnosticEntry {
|
||||||
|
range: Point::new(2, 8)..Point::new(2, 17),
|
||||||
|
diagnostic: Diagnostic {
|
||||||
|
severity: DiagnosticSeverity::ERROR,
|
||||||
|
message: "error 2".to_string(),
|
||||||
|
group_id: 1,
|
||||||
|
is_primary: true,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
buffer.diagnostic_group::<Point>(2).collect::<Vec<_>>(),
|
||||||
&[
|
&[
|
||||||
DiagnosticEntry {
|
DiagnosticEntry {
|
||||||
range: Point::new(1, 8)..Point::new(1, 9),
|
range: Point::new(1, 8)..Point::new(1, 9),
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
severity: DiagnosticSeverity::WARNING,
|
severity: DiagnosticSeverity::WARNING,
|
||||||
message: "error 1".to_string(),
|
message: "error 1".to_string(),
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
is_primary: true,
|
is_primary: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -3940,7 +3940,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
severity: DiagnosticSeverity::HINT,
|
severity: DiagnosticSeverity::HINT,
|
||||||
message: "error 1 hint 1".to_string(),
|
message: "error 1 hint 1".to_string(),
|
||||||
group_id: 1,
|
group_id: 2,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue