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()];
|
let line = &mut self.lines[self.cursor.line.get()];
|
||||||
line.reset();
|
line.reset();
|
||||||
|
|
||||||
for (i, c) in line.text.grapheme_indices(true) {
|
if let Some((i, c)) = line
|
||||||
if i == self.cursor.index {
|
.text
|
||||||
line.text.replace_range(i..(i + c.len()), "");
|
.grapheme_indices(true)
|
||||||
break;
|
.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() {
|
} else if self.cursor.line.get() + 1 < self.lines.len() {
|
||||||
let old_line = self.lines.remove(self.cursor.line.get() + 1);
|
let old_line = self.lines.remove(self.cursor.line.get() + 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue