From e46d1549d6869bdce7476ee360ae644e91b1298f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 6 Jun 2023 10:12:15 +0200 Subject: [PATCH] Retain selection's head (as opposed to its end) on insertion This makes a difference when an edit spans two excerpts and the selection start won't necessarily be the same as the selection end after the edit. --- crates/editor/src/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 453468349b..0eefa7e098 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2382,7 +2382,7 @@ impl Editor { old_selections .iter() .map(|s| { - let anchor = snapshot.anchor_after(s.end); + let anchor = snapshot.anchor_after(s.head()); s.map(|_| anchor) }) .collect::>()