Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jumplist support for the search (closes #1625) #1718

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions helix-term/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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() {
Expand Down