Fixed horizontal align of caret.

Config race condition no longer happens on this machine (only one where it happened)
This commit is contained in:
Samuel Guerra 2023-05-30 12:23:03 -03:00
parent fc2672b8c1
commit 3fadcf0597
2 changed files with 9 additions and 11 deletions

View File

@ -34,12 +34,6 @@
# Config
* Config test sometimes reads empty.
- Empty is written on init, then quickly filled with defaults for the write test.
- Maybe the empty write is happening after the filled somehow?
- Nope, tracing shows a full write request and commit.
- But the file is empty on error.. (empty as in `#` for TOML, not zero-sized)
* Review save debounce.
* Test concurrent access to same config.
- Use multiple app threads.

View File

@ -187,6 +187,11 @@ impl LineRangeVec {
self.0[index].width
}
/// Line x offset.
fn x_offset(&self, index: usize) -> f32 {
self.0[index].x_offset
}
/// Iter segment ranges.
fn iter_segs(&self) -> impl Iterator<Item = (f32, IndexRange)> + '_ {
self.iter_segs_skip(0)
@ -901,7 +906,7 @@ impl ShapedText {
let text_start = seg.text_range().start();
for ((g, advance), cluster) in seg.glyphs_with_x_advance().flat_map(|(_, gx)| gx).zip(seg.clusters()) {
for ((_, advance), cluster) in seg.glyphs_with_x_advance().flat_map(|(_, gx)| gx).zip(seg.clusters()) {
if text_start + *cluster as usize == index {
break;
}
@ -1839,16 +1844,15 @@ impl<'a> ShapedSegment<'a> {
fn x_width(&self) -> (Px, Px) {
let IndexRange(start, end) = self.glyphs_range();
// !!: TODO, check align
let is_line_break = start == end && matches!(self.kind(), TextSegmentKind::LineBreak);
let start_x = match self.direction() {
LayoutDirection::LTR => {
if is_line_break {
let s = self.text.lines.width(self.line_index);
return (Px(s as i32), Px(0));
let x = self.text.lines.x_offset(self.line_index);
let w = self.text.lines.width(self.line_index);
return (Px((x + w) as i32), Px(0));
}
self.text.glyphs[start].point.x
}
LayoutDirection::RTL => {