From e97ffa860eb7ed9487359e4337691ef585842a0b Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 12 May 2026 14:51:23 -0400 Subject: [PATCH] Show format selections for cursor ranges --- crates/editor/src/editor.rs | 1 - crates/editor/src/editor_tests.rs | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b8ff734b43e545..9763b20e870507 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -15281,7 +15281,6 @@ impl Editor { self.selections .disjoint_anchor_ranges() - .filter(|range| range.start != range.end) .flat_map(|range| [range.start, range.end]) .filter_map(|anchor| snapshot.anchor_to_buffer_anchor(anchor)) .filter_map(|(_, buffer_snapshot)| multi_buffer.buffer(buffer_snapshot.remote_id())) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index d71c3f4e4a2f49..930d79b5d9efd2 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -14728,6 +14728,24 @@ async fn test_format_selections_action_available_when_range_formatting_is_suppor assert!(cx.update(|window, cx| { window.is_action_available(&FormatSelections, cx) })); } +#[gpui::test] +async fn test_format_selections_action_available_for_cursor_when_range_formatting_is_supported( + cx: &mut TestAppContext, +) { + let (_, editor, cx, _) = setup_range_format_test(cx).await; + + editor.update_in(cx, |editor, window, cx| { + editor.set_text("foo\nbar\n", window, cx); + editor.change_selections(SelectionEffects::default(), window, cx, |s| { + s.select_ranges([Point::new(1, 1)..Point::new(1, 1)]); + }); + }); + + refresh_editor_actions(cx); + + assert!(cx.update(|window, cx| { window.is_action_available(&FormatSelections, cx) })); +} + #[gpui::test] async fn test_format_selections_action_hidden_without_range_formatting_support( cx: &mut TestAppContext,