From 6bdf609caaf4eb1c137f503f147d1e4e4f3e8676 Mon Sep 17 00:00:00 2001 From: BenoƮt CORTIER Date: Mon, 14 Jun 2021 23:26:05 -0400 Subject: 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. --- helix-view/src/editor.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'helix-view/src') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index ef0d8213..2fd01817 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -8,13 +8,15 @@ use slotmap::SlotMap; use anyhow::Error; pub use helix_core::diagnostic::Severity; +pub use helix_core::register::Registers; #[derive(Debug)] pub struct Editor { pub tree: Tree, pub documents: SlotMap, pub count: Option, - pub register: RegisterSelection, + pub selected_register: RegisterSelection, + pub registers: Registers, pub theme: Theme, pub language_servers: helix_lsp::Registry, @@ -59,9 +61,10 @@ impl Editor { tree: Tree::new(area), documents: SlotMap::with_key(), count: None, - register: RegisterSelection::default(), + selected_register: RegisterSelection::default(), theme, language_servers, + registers: Registers::default(), status_msg: None, } } @@ -239,6 +242,13 @@ impl Editor { (view, doc) } + pub fn current_with_registers(&mut self) -> (&mut View, &mut Document, &mut Registers) { + let view = self.tree.get_mut(self.tree.focus); + let doc = &mut self.documents[view.doc]; + let registers = &mut self.registers; + (view, doc, registers) + } + pub fn view(&self) -> &View { self.tree.get(self.tree.focus) } -- cgit v1.2.3-70-g09d2