From c74fec4c6e77972da36e1c929bada17d3a643f34 Mon Sep 17 00:00:00 2001 From: Nik Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Wed, 2 Apr 2025 00:12:38 +0100 Subject: [PATCH] fix?: do not block on the main thread when acquiring diff handle not sure if this will work as I can't reproduce this but let's see! --- helix-vcs/src/diff.rs | 7 +++++++ helix-view/src/document.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/helix-vcs/src/diff.rs b/helix-vcs/src/diff.rs index e49e171dd..95e13b594 100644 --- a/helix-vcs/src/diff.rs +++ b/helix-vcs/src/diff.rs @@ -75,6 +75,13 @@ impl DiffHandle { } } + pub fn try_load(&self) -> Option { + Some(Diff { + diff: self.diff.try_read()?, + inverted: self.inverted, + }) + } + /// Updates the document associated with this redraw handle /// This function is only intended to be called from within the rendering loop /// if called from elsewhere it may fail to acquire the render lock and panic diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index d0007a1fd..c99a4e75f 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1590,7 +1590,7 @@ impl Document { // file in the file system into what gix::blame knows about (gix::blame only // knows about commit history, it does not know about uncommitted changes) diff_handle - .load() + .try_load()? .hunks_intersecting_line_ranges(std::iter::once((0, cursor_line as usize))) .try_fold( (0, 0),