Fixed issue with delete_character_back
This commit is contained in:
parent
e08b8eb505
commit
381721013e
|
@ -80,6 +80,7 @@ impl EditorData {
|
|||
}
|
||||
|
||||
pub fn delete_char_back(&mut self) {
|
||||
// Delete selection
|
||||
if !self.select_range().is_empty() {
|
||||
let range = self.select_range();
|
||||
self.content.remove(self.select_range());
|
||||
|
@ -87,15 +88,9 @@ impl EditorData {
|
|||
return;
|
||||
}
|
||||
|
||||
// Cant delete character sif we are at the start of the buffer
|
||||
if self.cursor_pos > 0 {
|
||||
if self.cursor_pos == self.content.len_chars() {
|
||||
self.content
|
||||
.remove(self.content.len_chars()..self.content.len_chars());
|
||||
|
||||
// self.raw_content.pop();
|
||||
} else {
|
||||
self.content.remove((self.cursor_pos - 1)..self.cursor_pos);
|
||||
}
|
||||
self.content.remove((self.cursor_pos - 1)..self.cursor_pos);
|
||||
self.cursor_left();
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +225,7 @@ impl Widget<EditorData> for AbacusEditor {
|
|||
|
||||
if data.mode == EditMode::Normal {
|
||||
if let Some(char_rect) = layout
|
||||
.rects_for_range((data.cursor_pos.max(1) - 1)..data.cursor_pos)
|
||||
.rects_for_range(data.cursor_pos.max(1)..data.cursor_pos + 1)
|
||||
.last()
|
||||
{
|
||||
if char_rect.width() == 0. {
|
||||
|
|
Loading…
Reference in New Issue