Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Revert "Fix `editor::GoToDiagnostics` cycle (#24446)" (#24568)
Kirill Bulatov4f7200527cba
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 15317e09993..41050913957 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -10299,26 +10299,14 @@ impl Editor {if entry.diagnostic.is_primary&& entry.diagnostic.severity <= DiagnosticSeverity::WARNING&& entry.range.start != entry.range.end+ // if we match with the active diagnostic, skip it+ && Some(entry.diagnostic.group_id)+ != self.active_diagnostics.as_ref().map(|d| d.group_id){- let entry_group = entry.diagnostic.group_id;- let in_next_group = self.active_diagnostics.as_ref().map_or(- true,- |active| match direction {- Direction::Prev => {- entry_group != active.group_id- && (active.group_id == 0 || entry_group < active.group_id)- }- Direction::Next => {- entry_group != active.group_id- && (entry_group == 0 || entry_group > active.group_id)- }- },- );- if in_next_group {- return Some((entry.range, entry.diagnostic.group_id));- }+ Some((entry.range, entry.diagnostic.group_id))+ } else {+ None}- None});if let Some((primary_range, group_id)) = group {diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex 5247c629c06..68bd0514dd9 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -10653,176 +10653,6 @@ async fn go_to_prev_overlapping_diagnostic("});}-#[gpui::test]-async fn cycle_through_same_place_diagnostics(- executor: BackgroundExecutor,- cx: &mut gpui::TestAppContext,-) {- init_test(cx, |_| {});-- let mut cx = EditorTestContext::new(cx).await;- let lsp_store =- cx.update_editor(|editor, _, cx| editor.project.as_ref().unwrap().read(cx).lsp_store());-- cx.set_state(indoc! {"- ˇfn func(abc def: i32) -> u32 {- }- "});-- cx.update(|_, cx| {- lsp_store.update(cx, |lsp_store, cx| {- lsp_store- .update_diagnostics(- LanguageServerId(0),- lsp::PublishDiagnosticsParams {- uri: lsp::Url::from_file_path(path!("/root/file")).unwrap(),- version: None,- diagnostics: vec![- lsp::Diagnostic {- range: lsp::Range::new(- lsp::Position::new(0, 11),- lsp::Position::new(0, 12),- ),- severity: Some(lsp::DiagnosticSeverity::ERROR),- ..Default::default()- },- lsp::Diagnostic {- range: lsp::Range::new(- lsp::Position::new(0, 12),- lsp::Position::new(0, 15),- ),- severity: Some(lsp::DiagnosticSeverity::ERROR),- ..Default::default()- },- lsp::Diagnostic {- range: lsp::Range::new(- lsp::Position::new(0, 12),- lsp::Position::new(0, 15),- ),- severity: Some(lsp::DiagnosticSeverity::ERROR),- ..Default::default()- },- lsp::Diagnostic {- range: lsp::Range::new(- lsp::Position::new(0, 25),- lsp::Position::new(0, 28),- ),- severity: Some(lsp::DiagnosticSeverity::ERROR),- ..Default::default()- },- ],- },- &[],- cx,- )- .unwrap()- });- });- executor.run_until_parked();-- //// Backward-- // Fourth diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abc def: i32) -> ˇu32 {- }- "});-- // Third diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abc ˇdef: i32) -> u32 {- }- "});-- // Second diagnostic, same place- cx.update_editor(|editor, window, cx| {- editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abc ˇdef: i32) -> u32 {- }- "});-- // First diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abcˇ def: i32) -> u32 {- }- "});-- // Wrapped over, fourth diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abc def: i32) -> ˇu32 {- }- "});-- cx.update_editor(|editor, window, cx| {- editor.move_to_beginning(&MoveToBeginning, window, cx);- });- cx.assert_editor_state(indoc! {"- ˇfn func(abc def: i32) -> u32 {- }- "});-- //// Forward-- // First diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_diagnostic(&GoToDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abcˇ def: i32) -> u32 {- }- "});-- // Second diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_diagnostic(&GoToDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abc ˇdef: i32) -> u32 {- }- "});-- // Third diagnostic, same place- cx.update_editor(|editor, window, cx| {- editor.go_to_diagnostic(&GoToDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abc ˇdef: i32) -> u32 {- }- "});-- // Fourth diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_diagnostic(&GoToDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abc def: i32) -> ˇu32 {- }- "});-- // Wrapped around, first diagnostic- cx.update_editor(|editor, window, cx| {- editor.go_to_diagnostic(&GoToDiagnostic, window, cx);- });- cx.assert_editor_state(indoc! {"- fn func(abcˇ def: i32) -> u32 {- }- "});-}-#[gpui::test]async fn test_diagnostics_with_links(cx: &mut TestAppContext) {init_test(cx, |_| {});