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!
pull/13133/head
Nik Revenco 2025-04-02 00:12:38 +01:00
parent e8d7e76c73
commit c74fec4c6e
2 changed files with 8 additions and 1 deletions

View File

@ -75,6 +75,13 @@ impl DiffHandle {
} }
} }
pub fn try_load(&self) -> Option<Diff> {
Some(Diff {
diff: self.diff.try_read()?,
inverted: self.inverted,
})
}
/// Updates the document associated with this redraw handle /// Updates the document associated with this redraw handle
/// This function is only intended to be called from within the rendering loop /// 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 /// if called from elsewhere it may fail to acquire the render lock and panic

View File

@ -1590,7 +1590,7 @@ impl Document {
// file in the file system into what gix::blame knows about (gix::blame only // 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) // knows about commit history, it does not know about uncommitted changes)
diff_handle diff_handle
.load() .try_load()?
.hunks_intersecting_line_ranges(std::iter::once((0, cursor_line as usize))) .hunks_intersecting_line_ranges(std::iter::once((0, cursor_line as usize)))
.try_fold( .try_fold(
(0, 0), (0, 0),