on master help sign in
Add jumplist support for the search (closes #1625) (#1718)
49c5bc5Philipp Mildenberger
helix-term/src/ui/mod.rs+11−12
@@ -34,8 +34,8 @@ pub fn regex_prompt(
34 fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
34 fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
35) -> Prompt {
35) -> Prompt {
36 let (view, doc) = current!(cx.editor);
36 let (view, doc) = current!(cx.editor);
37− let view_id = view.id;
37+ let doc_id = view.doc;
38− let snapshot = doc.selection(view_id).clone();
38+ let snapshot = doc.selection(view.id).clone();
39 let offset_snapshot = view.offset;
39 let offset_snapshot = view.offset;
40
40
41 let mut prompt = Prompt::new(
41 let mut prompt = Prompt::new(
@@ -49,17 +49,16 @@ pub fn regex_prompt(
49 doc.set_selection(view.id, snapshot.clone());
49 doc.set_selection(view.id, snapshot.clone());
50 view.offset = offset_snapshot;
50 view.offset = offset_snapshot;
51 }
51 }
52− PromptEvent::Validate => {
52+ PromptEvent::Validate => match Regex::new(input) {
53− // TODO: push_jump to store selection just before jump
54−
55− match Regex::new(input) {
56− Ok(regex) => {
53+ Ok(regex) => {
57− let (view, doc) = current!(cx.editor);
54+ let (view, doc) = current!(cx.editor);
55+ // Equivalent to push_jump to store selection just before jump
56+ view.jumps.push((doc_id, snapshot.clone()));
58− fun(view, doc, regex, event);
57+ fun(view, doc, regex, event);
59− }
60− Err(_err) => (), // TODO: mark command line as error
61 }
58 }
59+ Err(_err) => (), // TODO: mark command line as error
62− }
60+ },
61+
63 PromptEvent::Update => {
62 PromptEvent::Update => {
64 // skip empty input, TODO: trigger default
63 // skip empty input, TODO: trigger default
65 if input.is_empty() {
64 if input.is_empty() {