From beeb42da2906cf576bed872fcb90264841560af0 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 2 Jun 2025 23:56:45 -0600 Subject: [PATCH] snippets: Show completions on first range in tabstop instead of last (#31939) Release Notes: - N/A --- crates/editor/src/editor.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index e68220eea955763b292509e1ce7ed682fcfa2dc4..796cbdac3788746bcbdbe5c0688b7a0d09bed0ec 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -8970,7 +8970,9 @@ impl Editor { }) }) .collect::>(); - tabstop_ranges.sort_unstable_by(|a, b| a.start.cmp(&b.start, snapshot)); + // Sort in reverse order so that the first range is the newest created + // selection. Completions will use it and autoscroll will prioritize it. + tabstop_ranges.sort_unstable_by(|a, b| b.start.cmp(&a.start, snapshot)); Tabstop { is_end_tabstop, @@ -9098,7 +9100,7 @@ impl Editor { } if let Some(current_ranges) = snippet.ranges.get(snippet.active_index) { self.change_selections(Some(Autoscroll::fit()), window, cx, |s| { - s.select_anchor_ranges(current_ranges.iter().cloned()) + s.select_ranges(current_ranges.iter().cloned()) }); if let Some(choices) = &snippet.choices[snippet.active_index] {