mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Fix boundary condition in buffer_line_len when at the end of a file
co-authored-by: max <max@zed.dev>
This commit is contained in:
parent
eba119b914
commit
c39b4ac229
3 changed files with 6 additions and 3 deletions
|
@ -641,7 +641,7 @@ impl DisplaySnapshot {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for next_row in (buffer_row + 1)..max_row {
|
for next_row in (buffer_row + 1)..=max_row {
|
||||||
let (next_indent_size, next_line_is_blank) = self.line_indent_for_buffer_row(next_row);
|
let (next_indent_size, next_line_is_blank) = self.line_indent_for_buffer_row(next_row);
|
||||||
if next_indent_size > indent_size {
|
if next_indent_size > indent_size {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -5772,7 +5772,6 @@ impl Editor {
|
||||||
|
|
||||||
pub fn fold_at(&mut self, fold_at: &FoldAt, cx: &mut ViewContext<Self>) {
|
pub fn fold_at(&mut self, fold_at: &FoldAt, cx: &mut ViewContext<Self>) {
|
||||||
let buffer_row = fold_at.buffer_row;
|
let buffer_row = fold_at.buffer_row;
|
||||||
|
|
||||||
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
|
|
||||||
if let Some(fold_range) = display_map.foldable_range(buffer_row) {
|
if let Some(fold_range) = display_map.foldable_range(buffer_row) {
|
||||||
|
|
|
@ -2194,7 +2194,11 @@ impl MultiBufferSnapshot {
|
||||||
|
|
||||||
pub fn buffer_line_for_row(&self, row: u32) -> Option<(&BufferSnapshot, Range<Point>)> {
|
pub fn buffer_line_for_row(&self, row: u32) -> Option<(&BufferSnapshot, Range<Point>)> {
|
||||||
let mut cursor = self.excerpts.cursor::<Point>();
|
let mut cursor = self.excerpts.cursor::<Point>();
|
||||||
cursor.seek(&Point::new(row, 0), Bias::Right, &());
|
let point = Point::new(row, 0);
|
||||||
|
cursor.seek(&point, Bias::Right, &());
|
||||||
|
if cursor.item().is_none() && *cursor.start() == point {
|
||||||
|
cursor.prev(&());
|
||||||
|
}
|
||||||
if let Some(excerpt) = cursor.item() {
|
if let Some(excerpt) = cursor.item() {
|
||||||
let overshoot = row - cursor.start().row;
|
let overshoot = row - cursor.start().row;
|
||||||
let excerpt_start = excerpt.range.context.start.to_point(&excerpt.buffer);
|
let excerpt_start = excerpt.range.context.start.to_point(&excerpt.buffer);
|
||||||
|
|
Loading…
Reference in a new issue