Use correct range to get diff hunks in the presence of wrapped lines

This commit is contained in:
Julia 2022-10-13 13:52:44 -04:00
parent a6a7e85894
commit 9c47325c25
5 changed files with 19 additions and 3 deletions

View file

@ -157,6 +157,7 @@ pub struct BlockChunks<'a> {
max_output_row: u32,
}
#[derive(Clone)]
pub struct BlockBufferRows<'a> {
transforms: sum_tree::Cursor<'a, Transform, (BlockRow, WrapRow)>,
input_buffer_rows: wrap_map::WrapBufferRows<'a>,

View file

@ -987,6 +987,7 @@ impl<'a> sum_tree::Dimension<'a, FoldSummary> for usize {
}
}
#[derive(Clone)]
pub struct FoldBufferRows<'a> {
cursor: Cursor<'a, Transform, (FoldPoint, Point)>,
input_buffer_rows: MultiBufferRows<'a>,

View file

@ -62,6 +62,7 @@ pub struct WrapChunks<'a> {
transforms: Cursor<'a, Transform, (WrapPoint, TabPoint)>,
}
#[derive(Clone)]
pub struct WrapBufferRows<'a> {
input_buffer_rows: fold_map::FoldBufferRows<'a>,
input_buffer_row: Option<u32>,

View file

@ -1042,15 +1042,27 @@ impl EditorElement {
rows: Range<u32>,
snapshot: &EditorSnapshot,
) -> Vec<DiffHunkLayout> {
let buffer_rows = snapshot.buffer_rows(rows.start);
let start_actual_row = match buffer_rows
.clone()
.take((rows.end - rows.start) as usize)
.find_map(|b| b)
{
Some(start_actual_row) => start_actual_row,
None => return Vec::new(),
};
//Get all hunks after our starting actual buffer row
//The loop is in terms of visual buffer rows so we simply
//return before touching any hunks past the end of the view
let mut diff_hunks = snapshot
.buffer_snapshot
.git_diff_hunks_in_range(rows.clone())
.git_diff_hunks_in_range(start_actual_row..u32::MAX)
.peekable();
//Some number followed by Nones for wrapped lines
//Jump in number for folded lines
let mut buffer_rows = snapshot
.buffer_rows(rows.start)
let mut buffer_rows = buffer_rows
.take((rows.end - rows.start) as usize)
.enumerate()
.peekable();

View file

@ -143,6 +143,7 @@ struct ExcerptSummary {
text: TextSummary,
}
#[derive(Clone)]
pub struct MultiBufferRows<'a> {
buffer_row_range: Range<u32>,
excerpts: Cursor<'a, Excerpt, Point>,