mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Fix backward search from command
This commit is contained in:
parent
a25fcfdfa7
commit
a59da3634b
@ -355,8 +355,33 @@ mod test {
|
|||||||
dd
|
dd
|
||||||
ˇcc"})
|
ˇcc"})
|
||||||
.await;
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
cx.simulate_shared_keystrokes([":", "%", "s", "/", "/", "/", "enter"])
|
#[gpui::test]
|
||||||
|
async fn test_command_search(cx: &mut TestAppContext) {
|
||||||
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
|
||||||
|
cx.set_shared_state(indoc! {"
|
||||||
|
ˇa
|
||||||
|
b
|
||||||
|
a
|
||||||
|
c"})
|
||||||
|
.await;
|
||||||
|
cx.simulate_shared_keystrokes([":", "/", "b", "enter"])
|
||||||
|
.await;
|
||||||
|
cx.assert_shared_state(indoc! {"
|
||||||
|
a
|
||||||
|
ˇb
|
||||||
|
a
|
||||||
|
c"})
|
||||||
|
.await;
|
||||||
|
cx.simulate_shared_keystrokes([":", "?", "a", "enter"])
|
||||||
|
.await;
|
||||||
|
cx.assert_shared_state(indoc! {"
|
||||||
|
ˇa
|
||||||
|
b
|
||||||
|
a
|
||||||
|
c"})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,10 +195,15 @@ fn find_command(workspace: &mut Workspace, action: &FindCommand, cx: &mut ViewCo
|
|||||||
});
|
});
|
||||||
let Some(search) = search else { return };
|
let Some(search) = search else { return };
|
||||||
let search_bar = search_bar.downgrade();
|
let search_bar = search_bar.downgrade();
|
||||||
|
let direction = if action.backwards {
|
||||||
|
Direction::Prev
|
||||||
|
} else {
|
||||||
|
Direction::Next
|
||||||
|
};
|
||||||
cx.spawn(|_, mut cx| async move {
|
cx.spawn(|_, mut cx| async move {
|
||||||
search.await?;
|
search.await?;
|
||||||
search_bar.update(&mut cx, |search_bar, cx| {
|
search_bar.update(&mut cx, |search_bar, cx| {
|
||||||
search_bar.select_match(Direction::Next, 1, cx)
|
search_bar.select_match(direction, 1, cx)
|
||||||
})?;
|
})?;
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
})
|
})
|
||||||
|
11
crates/vim/test_data/test_command_search.json
Normal file
11
crates/vim/test_data/test_command_search.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{"Put":{"state":"ˇa\nb\na\nc"}}
|
||||||
|
{"Key":":"}
|
||||||
|
{"Key":"/"}
|
||||||
|
{"Key":"b"}
|
||||||
|
{"Key":"enter"}
|
||||||
|
{"Get":{"state":"a\nˇb\na\nc","mode":"Normal"}}
|
||||||
|
{"Key":":"}
|
||||||
|
{"Key":"?"}
|
||||||
|
{"Key":"a"}
|
||||||
|
{"Key":"enter"}
|
||||||
|
{"Get":{"state":"ˇa\nb\na\nc","mode":"Normal"}}
|
Loading…
Reference in New Issue
Block a user