Fix moving to end of last line
This commit is contained in:
parent
4bf6d80988
commit
51d03c6fe2
1 changed files with 5 additions and 2 deletions
|
|
@ -141,16 +141,19 @@ impl InnerEditorState {
|
|||
let (start, end) = self.line(line);
|
||||
let line = &self.text[start..end];
|
||||
|
||||
self.idx = start;
|
||||
let mut width = 0;
|
||||
for (gi, g) in line.grapheme_indices(true) {
|
||||
self.idx = start + gi;
|
||||
if col > width {
|
||||
width += frame.grapheme_width(g, width) as usize;
|
||||
} else {
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if !line.ends_with('\n') {
|
||||
self.idx = end;
|
||||
}
|
||||
}
|
||||
|
||||
fn record_cursor_col(&mut self, frame: &mut Frame) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue