co-authored-by: conrad <conrad.irwin@zed.dev>
This commit is contained in:
Mikayla
2023-11-13 15:53:04 -08:00
co-authored by conrad
parent 0e3fd92bd0
commit a4e9fea133
15 changed files with 3384 additions and 383 deletions
+2 -2
View File
@@ -54,9 +54,9 @@ impl LineLayout {
pub fn closest_index_for_x(&self, x: Pixels) -> usize {
let mut prev_index = 0;
let mut prev_x = px(0.);
for run in self.runs.iter() {
for glyph in run.glyphs.iter() {
glyph.index;
if glyph.position.x >= x {
if glyph.position.x - x < x - prev_x {
return glyph.index;
@@ -68,7 +68,7 @@ impl LineLayout {
prev_x = glyph.position.x;
}
}
prev_index
prev_index + 1
}
pub fn x_for_index(&self, index: usize) -> Pixels {