summaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorLeoi Hung Kin2021-09-21 16:03:12 +0000
committerGitHub2021-09-21 16:03:12 +0000
commit9456d5c1a258e71bbb7e391dec8c3efb819e2d7d (patch)
tree11ecd447d52866168082d06701fc1cfb8612bea4 /helix-term/src/ui
parenta512f48e4574f7465dceecb89c4dbbfa9e21ff6f (diff)
Initial implementation of global search (#651)
* initial implementation of global search * use tokio::sync::mpsc::unbounded_channel instead of Arc, Mutex, Waker poll_fn * use tokio_stream::wrappers::UnboundedReceiverStream to collect all search matches * regex_prompt: unified callback; refactor * global search doc
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/mod.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index f6536eb2..810a9966 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -29,7 +29,7 @@ pub fn regex_prompt(
cx: &mut crate::commands::Context,
prompt: std::borrow::Cow<'static, str>,
history_register: Option<char>,
- fun: impl Fn(&mut View, &mut Document, Regex) + 'static,
+ fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
) -> Prompt {
let (view, doc) = current!(cx.editor);
let view_id = view.id;
@@ -47,6 +47,14 @@ pub fn regex_prompt(
}
PromptEvent::Validate => {
// TODO: push_jump to store selection just before jump
+
+ match Regex::new(input) {
+ Ok(regex) => {
+ let (view, doc) = current!(cx.editor);
+ fun(view, doc, regex, event);
+ }
+ Err(_err) => (), // TODO: mark command line as error
+ }
}
PromptEvent::Update => {
// skip empty input, TODO: trigger default
@@ -70,7 +78,7 @@ pub fn regex_prompt(
// revert state to what it was before the last update
doc.set_selection(view.id, snapshot.clone());
- fun(view, doc, regex);
+ fun(view, doc, regex, event);
view.ensure_cursor_in_view(doc, cx.editor.config.scrolloff);
}