mirror of https://github.com/helix-editor/helix
parent
14e2ced440
commit
49c5bc5934
|
@ -34,8 +34,8 @@ pub fn regex_prompt(
|
||||||
fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
|
fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
|
||||||
) -> Prompt {
|
) -> Prompt {
|
||||||
let (view, doc) = current!(cx.editor);
|
let (view, doc) = current!(cx.editor);
|
||||||
let view_id = view.id;
|
let doc_id = view.doc;
|
||||||
let snapshot = doc.selection(view_id).clone();
|
let snapshot = doc.selection(view.id).clone();
|
||||||
let offset_snapshot = view.offset;
|
let offset_snapshot = view.offset;
|
||||||
|
|
||||||
let mut prompt = Prompt::new(
|
let mut prompt = Prompt::new(
|
||||||
|
@ -49,17 +49,16 @@ pub fn regex_prompt(
|
||||||
doc.set_selection(view.id, snapshot.clone());
|
doc.set_selection(view.id, snapshot.clone());
|
||||||
view.offset = offset_snapshot;
|
view.offset = offset_snapshot;
|
||||||
}
|
}
|
||||||
PromptEvent::Validate => {
|
PromptEvent::Validate => match Regex::new(input) {
|
||||||
// TODO: push_jump to store selection just before jump
|
Ok(regex) => {
|
||||||
|
let (view, doc) = current!(cx.editor);
|
||||||
match Regex::new(input) {
|
// Equivalent to push_jump to store selection just before jump
|
||||||
Ok(regex) => {
|
view.jumps.push((doc_id, snapshot.clone()));
|
||||||
let (view, doc) = current!(cx.editor);
|
fun(view, doc, regex, event);
|
||||||
fun(view, doc, regex, event);
|
|
||||||
}
|
|
||||||
Err(_err) => (), // TODO: mark command line as error
|
|
||||||
}
|
}
|
||||||
}
|
Err(_err) => (), // TODO: mark command line as error
|
||||||
|
},
|
||||||
|
|
||||||
PromptEvent::Update => {
|
PromptEvent::Update => {
|
||||||
// skip empty input, TODO: trigger default
|
// skip empty input, TODO: trigger default
|
||||||
if input.is_empty() {
|
if input.is_empty() {
|
||||||
|
|
Loading…
Reference in New Issue