Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7754,7 +7754,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()))
Expand Down
18 changes: 18 additions & 0 deletions crates/editor/src/editor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14873,6 +14873,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,
Expand Down
Loading