summaryrefslogtreecommitdiff
path: root/helix-term/src/ui/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r--helix-term/src/ui/mod.rs42
1 files changed, 38 insertions, 4 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 60ad3b24..6ac4dbb7 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -1,5 +1,6 @@
mod completion;
pub(crate) mod editor;
+mod fuzzy_match;
mod info;
pub mod lsp;
mod markdown;
@@ -12,6 +13,8 @@ mod spinner;
mod statusline;
mod text;
+use crate::compositor::{Component, Compositor};
+use crate::job;
pub use completion::Completion;
pub use editor::EditorView;
pub use markdown::Markdown;
@@ -24,7 +27,7 @@ pub use text::Text;
use helix_core::regex::Regex;
use helix_core::regex::RegexBuilder;
-use helix_view::{Document, Editor, View};
+use helix_view::Editor;
use std::path::PathBuf;
@@ -59,7 +62,7 @@ pub fn regex_prompt(
prompt: std::borrow::Cow<'static, str>,
history_register: Option<char>,
completion_fn: impl FnMut(&Editor, &str) -> Vec<prompt::Completion> + 'static,
- fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
+ fun: impl Fn(&mut Editor, Regex, PromptEvent) + 'static,
) {
let (view, doc) = current!(cx.editor);
let doc_id = view.doc;
@@ -106,11 +109,42 @@ pub fn regex_prompt(
view.jumps.push((doc_id, snapshot.clone()));
}
- fun(view, doc, regex, event);
+ fun(cx.editor, regex, event);
+ let (view, doc) = current!(cx.editor);
view.ensure_cursor_in_view(doc, config.scrolloff);
}
- Err(_err) => (), // TODO: mark command line as error
+ Err(err) => {
+ let (view, doc) = current!(cx.editor);
+ doc.set_selection(view.id, snapshot.clone());
+ view.offset = offset_snapshot;
+
+ if event == PromptEvent::Validate {
+ let callback = async move {
+ let call: job::Callback = Box::new(
+ move |_editor: &mut Editor, compositor: &mut Compositor| {
+ let contents = Text::new(format!("{}", err));
+ let size = compositor.size();
+ let mut popup = Popup::new("invalid-regex", contents)
+ .position(Some(helix_core::Position::new(
+ size.height as usize - 2, // 2 = statusline + commandline
+ 0,
+ )))
+ .auto_close(true);
+ popup.required_size((size.width, size.height));
+
+ compositor.replace_or_push("invalid-regex", popup);
+ },
+ );
+ Ok(call)
+ };
+
+ cx.jobs.callback(callback);
+ } else {
+ // Update
+ // TODO: mark command line as error
+ }
+ }
}
}
}