From 2ba3262f29168f100bac153fd77f4768746f2fe2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 9 Jun 2023 10:56:58 +0300 Subject: [PATCH] Add line_len snapshot method Co-Authored-By: Antonio Scandurra --- crates/editor/src/display_map/inlay_map.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index ceba38388b6380fb0823a64c5337955189bfdddf..529b056eaf2cb59cce376f819df40c6ef6364125 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -549,7 +549,7 @@ impl InlaySnapshot { match bias { Bias::Left => cursor.end(&()), - Bias::Right => *cursor.start(), + Bias::Right => cursor.start(), } } @@ -618,8 +618,13 @@ impl InlaySnapshot { } pub fn line_len(&self, row: u32) -> u32 { - // TODO kb copied from suggestion_map - self.suggestion_snapshot.line_len(row) + let line_start = self.to_offset(InlayPoint::new(row, 0)).0; + let line_end = if row >= self.max_point().row() { + self.len().0 + } else { + self.to_offset(InlayPoint::new(row + 1, 0)).0 - 1 + }; + (line_end - line_start) as u32 } pub fn chunks<'a>(