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-view/src | |
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-view/src')
-rw-r--r-- | helix-view/src/editor.rs | 14 |
1 files changed, 12 insertions, 2 deletions
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<DocumentId, Document>, pub count: Option<std::num::NonZeroUsize>, - 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) } |