diff options
author | Philipp Mildenberger | 2022-03-01 11:57:57 +0000 |
---|---|---|
committer | GitHub | 2022-03-01 11:57:57 +0000 |
commit | 49c5bc59340c05a7fb79e29bad5452fb8d3d9b4f (patch) | |
tree | 99cf8953ff89135b164970331cd69679118efc3c /helix-term/src | |
parent | 14e2ced440a2ba0f1794644f5cc1295a5738ad36 (diff) |
Add jumplist support for the search (closes #1625) (#1718)
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/ui/mod.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 6ebe7f3a..011ad9ba 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -34,8 +34,8 @@ pub fn regex_prompt( fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static, ) -> Prompt { let (view, doc) = current!(cx.editor); - let view_id = view.id; - let snapshot = doc.selection(view_id).clone(); + let doc_id = view.doc; + let snapshot = doc.selection(view.id).clone(); let offset_snapshot = view.offset; let mut prompt = Prompt::new( @@ -49,17 +49,16 @@ pub fn regex_prompt( doc.set_selection(view.id, snapshot.clone()); view.offset = offset_snapshot; } - 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::Validate => match Regex::new(input) { + Ok(regex) => { + let (view, doc) = current!(cx.editor); + // Equivalent to push_jump to store selection just before jump + view.jumps.push((doc_id, snapshot.clone())); + fun(view, doc, regex, event); } - } + Err(_err) => (), // TODO: mark command line as error + }, + PromptEvent::Update => { // skip empty input, TODO: trigger default if input.is_empty() { |