Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Clear SelectionGoal on input

Conrad Irwinf1c743286dc0
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index e0b8af1c71c..24ffa64a6af 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -2454,7 +2454,13 @@ impl Editor {
let snapshot = this.buffer.read(cx).read(cx);
let new_selections = resolve_multiple::<usize, _>(new_anchor_selections, &snapshot)
.zip(new_selection_deltas)
- .map(|(selection, delta)| selection.map(|e| e + delta))
+ .map(|(selection, delta)| Selection {
+ id: selection.id,
+ start: selection.start + delta,
+ end: selection.end + delta,
+ reversed: selection.reversed,
+ goal: SelectionGoal::None,
+ })
.collect::<Vec<_>>();
let mut i = 0;
diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs
index 82e4cc68630..52dcb54ce24 100644
--- a/crates/vim/src/test.rs
+++ b/crates/vim/src/test.rs
@@ -635,3 +635,20 @@ async fn test_zero(cx: &mut gpui::TestAppContext) {
the lazy dog"})
.await;
}
+
+#[gpui::test]
+async fn test_selection_goal(cx: &mut gpui::TestAppContext) {
+ let mut cx = NeovimBackedTestContext::new(cx).await;
+
+ cx.set_shared_state(indoc! {"
+ ;;ˇ;
+ Lorem Ipsum"})
+ .await;
+
+ cx.simulate_shared_keystrokes(["a", "down", "up", ";", "down", "up"])
+ .await;
+ cx.assert_shared_state(indoc! {"
+ ;;;;ˇ
+ Lorem Ipsum"})
+ .await;
+}
diff --git a/crates/vim/test_data/test_selection_goal.json b/crates/vim/test_data/test_selection_goal.json
new file mode 100644
index 00000000000..ada2ab4c8e1
--- /dev/null
+++ b/crates/vim/test_data/test_selection_goal.json
@@ -0,0 +1,8 @@
+{"Put":{"state":";;ˇ;\nLorem Ipsum"}}
+{"Key":"a"}
+{"Key":"down"}
+{"Key":"up"}
+{"Key":";"}
+{"Key":"down"}
+{"Key":"up"}
+{"Get":{"state":";;;;ˇ\nLorem Ipsum","mode":"Insert"}}