diff options
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/Cargo.toml | 1 | ||||
-rw-r--r-- | helix-view/src/document.rs | 9 | ||||
-rw-r--r-- | helix-view/src/editor.rs | 13 |
3 files changed, 8 insertions, 15 deletions
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml index daaac59d..6218e9e4 100644 --- a/helix-view/Cargo.toml +++ b/helix-view/Cargo.toml @@ -17,6 +17,7 @@ term = ["crossterm"] bitflags = "2.4" anyhow = "1" helix-core = { version = "0.6", path = "../helix-core" } +helix-event = { version = "0.6", path = "../helix-event" } helix-loader = { version = "0.6", path = "../helix-loader" } helix-lsp = { version = "0.6", path = "../helix-lsp" } helix-dap = { version = "0.6", path = "../helix-dap" } diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 08b57f21..19f37c71 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -33,7 +33,7 @@ use helix_core::{ ChangeSet, Diagnostic, LineEnding, Range, Rope, RopeBuilder, Selection, Syntax, Transaction, }; -use crate::editor::{Config, RedrawHandle}; +use crate::editor::Config; use crate::{DocumentId, Editor, Theme, View, ViewId}; /// 8kB of buffer space for encoding and decoding `Rope`s. @@ -995,7 +995,6 @@ impl Document { &mut self, view: &mut View, provider_registry: &DiffProviderRegistry, - redraw_handle: RedrawHandle, ) -> Result<(), Error> { let encoding = self.encoding; let path = self @@ -1023,7 +1022,7 @@ impl Document { self.detect_indent_and_line_ending(); match provider_registry.get_diff_base(&path) { - Some(diff_base) => self.set_diff_base(diff_base, redraw_handle), + Some(diff_base) => self.set_diff_base(diff_base), None => self.diff_handle = None, } @@ -1583,13 +1582,13 @@ impl Document { } /// Intialize/updates the differ for this document with a new base. - pub fn set_diff_base(&mut self, diff_base: Vec<u8>, redraw_handle: RedrawHandle) { + pub fn set_diff_base(&mut self, diff_base: Vec<u8>) { if let Ok((diff_base, ..)) = from_reader(&mut diff_base.as_slice(), Some(self.encoding)) { if let Some(differ) = &self.diff_handle { differ.update_diff_base(diff_base); return; } - self.diff_handle = Some(DiffHandle::new(diff_base, self.text.clone(), redraw_handle)) + self.diff_handle = Some(DiffHandle::new(diff_base, self.text.clone())) } else { self.diff_handle = None; } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 94d0a852..86f35e0d 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -32,7 +32,7 @@ use std::{ use tokio::{ sync::{ mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}, - oneshot, Notify, RwLock, + oneshot, }, time::{sleep, Duration, Instant, Sleep}, }; @@ -925,10 +925,6 @@ pub struct Editor { pub exit_code: i32, pub config_events: (UnboundedSender<ConfigEvent>, UnboundedReceiver<ConfigEvent>), - /// Allows asynchronous tasks to control the rendering - /// The `Notify` allows asynchronous tasks to request the editor to perform a redraw - /// The `RwLock` blocks the editor from performing the render until an exclusive lock can be acquired - pub redraw_handle: RedrawHandle, pub needs_redraw: bool, /// Cached position of the cursor calculated during rendering. /// The content of `cursor_cache` is returned by `Editor::cursor` if @@ -955,8 +951,6 @@ pub struct Editor { pub type Motion = Box<dyn Fn(&mut Editor)>; -pub type RedrawHandle = (Arc<Notify>, Arc<RwLock<()>>); - #[derive(Debug)] pub enum EditorEvent { DocumentSaved(DocumentSavedEventResult), @@ -1062,7 +1056,6 @@ impl Editor { auto_pairs, exit_code: 0, config_events: unbounded_channel(), - redraw_handle: Default::default(), needs_redraw: false, cursor_cache: Cell::new(None), completion_request_handle: None, @@ -1453,7 +1446,7 @@ impl Editor { )?; if let Some(diff_base) = self.diff_providers.get_diff_base(&path) { - doc.set_diff_base(diff_base, self.redraw_handle.clone()); + doc.set_diff_base(diff_base); } doc.set_version_control_head(self.diff_providers.get_current_head_name(&path)); @@ -1752,7 +1745,7 @@ impl Editor { return EditorEvent::DebuggerEvent(event) } - _ = self.redraw_handle.0.notified() => { + _ = helix_event::redraw_requested() => { if !self.needs_redraw{ self.needs_redraw = true; let timeout = Instant::now() + Duration::from_millis(33); |