| 221 | } |
| 222 | |
| 223 | pub fn delete_char_forward(&mut self) { |
| 224 | if self.delete_selection() { |
| 225 | return; |
| 226 | } |
| 227 | let char_idx = self.cursor_char_idx(); |
| 228 | if char_idx >= self.document.len_chars() { |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | let cursor_before = self.cursor; |
| 233 | let end = self.document.next_grapheme_boundary(char_idx); |
| 234 | let deleted = self.document.slice_text(char_idx, end); |
| 235 | self.document.remove_char_range(char_idx, end); |
| 236 | self.cursor.clamp_to_document(&self.document); |
| 237 | self.push_undo(UndoRecord { |
| 238 | start: char_idx, |
| 239 | inserted: String::new(), |
| 240 | deleted, |
| 241 | cursor_before, |
| 242 | }); |
| 243 | } |
| 244 | |
| 245 | pub fn delete_char_backward(&mut self) { |
| 246 | if self.delete_selection() { |