Fix edge cases relating to running Delete with your cursor half way through an egc.
This commit is contained in:
parent
d6d896688f
commit
e14588b2f6
1 changed files with 8 additions and 5 deletions
|
|
@ -645,11 +645,14 @@ impl<'a> TextBuffer<'a> {
|
|||
let line = &mut self.lines[self.cursor.line.get()];
|
||||
line.reset();
|
||||
|
||||
for (i, c) in line.text.grapheme_indices(true) {
|
||||
if i == self.cursor.index {
|
||||
line.text.replace_range(i..(i + c.len()), "");
|
||||
break;
|
||||
}
|
||||
if let Some((i, c)) = line
|
||||
.text
|
||||
.grapheme_indices(true)
|
||||
.take_while(|(i, c)| *i <= self.cursor.index)
|
||||
.last()
|
||||
{
|
||||
line.text.replace_range(i..(i + c.len()), "");
|
||||
self.cursor.index = i;
|
||||
}
|
||||
} else if self.cursor.line.get() + 1 < self.lines.len() {
|
||||
let old_line = self.lines.remove(self.cursor.line.get() + 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue