Fixed caret not in char boundary panic.
This commit is contained in:
parent
8da9039456
commit
9b35d23288
|
@ -4,6 +4,7 @@
|
|||
- Caret vertical position incorrect when not aligned to the top.
|
||||
- `ShapedSegment::rect` return wrong value.
|
||||
- `ShapedLine::rect` return wrong value for mid lines?
|
||||
- After TextInput size increases to fit text caret cannot be moved with arrows.
|
||||
- Caret stops blinking while moving with cursor, not resetting timer?
|
||||
- Caret animation does not start visible (on focus).
|
||||
|
||||
|
|
|
@ -448,7 +448,17 @@ impl SegmentedText {
|
|||
.rev();
|
||||
iter.next().unwrap_or(0)
|
||||
} else {
|
||||
let s = &self.text.as_str()[..=from];
|
||||
let s = self.text.as_str();
|
||||
|
||||
// from + 1_char, so that the `from` is the first yield in reverse if it is a valid grapheme boundary
|
||||
let inclusive_from = s[from..]
|
||||
.char_indices()
|
||||
.skip(1)
|
||||
.next()
|
||||
.map(|(b, _)| from + b)
|
||||
.unwrap_or_else(|| s.len());
|
||||
|
||||
let s = &self.text.as_str()[..inclusive_from];
|
||||
let mut iter = unicode_segmentation::UnicodeSegmentation::grapheme_indices(s, true)
|
||||
.map(|(i, _)| i)
|
||||
.rev();
|
||||
|
|
Loading…
Reference in New Issue