aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/mod.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-01 01:39:46 +0000
committerBlaž Hrastnik2021-04-01 02:01:26 +0000
commit0dbd5b61ef4b75ba141b0b52636f3ba7c61c70cb (patch)
treed831ce257c3333d338ac41c235afac295bd90bf0 /helix-term/src/ui/mod.rs
parentceea5eacd814c5bbd8c6789610c87a882e3d72cf (diff)
Simplify code by providin cx.current() = (view, doc).
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r--helix-term/src/ui/mod.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 479e684a..8cbf706e 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -45,11 +45,8 @@ pub fn regex_prompt(
match event {
PromptEvent::Abort => {
// TODO: also revert text
- let view = editor.view();
- let view_id = view.id;
- let id = view.doc;
- let doc = &mut editor.documents[id];
- doc.set_selection(view_id, snapshot.clone());
+ let (view, doc) = editor.current();
+ doc.set_selection(view.id, snapshot.clone());
}
PromptEvent::Validate => {
// TODO: push_jump to store selection just before jump
@@ -62,19 +59,15 @@ pub fn regex_prompt(
match Regex::new(input) {
Ok(regex) => {
- // let view = &mut editor.view_mut();
- let view = editor.view();
- let view_id = view.id;
- let id = view.doc;
- let doc = &mut editor.documents[id];
+ let (view, doc) = editor.current();
// revert state to what it was before the last update
// TODO: also revert text
- doc.set_selection(view_id, snapshot.clone());
+ doc.set_selection(view.id, snapshot.clone());
fun(doc, regex);
- editor.ensure_cursor_in_view(view_id);
+ view.ensure_cursor_in_view(doc);
}
Err(_err) => (), // TODO: mark command line as error
}