diff options
author | BenoƮt CORTIER | 2021-06-15 03:26:05 +0000 |
---|---|---|
committer | Ivan Tham | 2021-06-15 15:01:56 +0000 |
commit | 6bdf609caaf4eb1c137f503f147d1e4e4f3e8676 (patch) | |
tree | 6de0864a077dd6bdea6f956ece264542a3ebeee7 /helix-term/src/ui/mod.rs | |
parent | 6fb2d2679dc63ca34be0d02efb543c3e0b49cb74 (diff) |
Remove RwLock for registers
Registers are stored inside `Editor` and accessed without `RwLock`.
To work around ownership, I added a sister method to `Editor::current`:
`Editor::current_with_context`. I tried to modify `Editor::current`
directly but it's used at a lot of places so I reverted into this for
now at least.
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r-- | helix-term/src/ui/mod.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 7e4464bc..77e53690 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -20,6 +20,7 @@ pub use tui::layout::Rect; pub use tui::style::{Color, Modifier, Style}; use helix_core::regex::Regex; +use helix_core::register::Registers; use helix_view::{Document, Editor, View}; use std::path::{Path, PathBuf}; @@ -27,7 +28,7 @@ use std::path::{Path, PathBuf}; pub fn regex_prompt( cx: &mut crate::commands::Context, prompt: String, - fun: impl Fn(&mut View, &mut Document, Regex) + 'static, + fun: impl Fn(&mut View, &mut Document, &mut Registers, Regex) + 'static, ) -> Prompt { let view_id = cx.view().id; let snapshot = cx.doc().selection(view_id).clone(); @@ -53,13 +54,13 @@ pub fn regex_prompt( match Regex::new(input) { Ok(regex) => { - let (view, doc) = editor.current(); + let (view, doc, registers) = editor.current_with_registers(); // revert state to what it was before the last update // TODO: also revert text doc.set_selection(view.id, snapshot.clone()); - fun(view, doc, regex); + fun(view, doc, registers, regex); view.ensure_cursor_in_view(doc); } |