Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,11 @@ impl App {
Ok(true)
}
KeyCode::Backspace => {
self.backend.delete_character_from_current_buffer();
self.backend.delete_character_before_cursor();
Ok(true)
}
KeyCode::Delete => {
self.backend.delete_char_under_cursor();
Ok(true)
}
_ => Ok(false),
Expand Down
12 changes: 11 additions & 1 deletion src/pike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Pike {
}

/// Deletes a characted and moves the cursor left
pub fn delete_character_from_current_buffer(&mut self) {
pub fn delete_character_before_cursor(&mut self) {
if let Some(buffer) = &mut self.workspace.current_buffer {
let pos = buffer.cursor.position;

Expand Down Expand Up @@ -191,6 +191,16 @@ impl Pike {
}
}

pub fn delete_char_under_cursor(&mut self) {
if let Some(buffer) = &mut self.workspace.current_buffer {
let pos = buffer.cursor.position;

self.cursor_history.record_undo_position(pos);

buffer.delete();
}
}

/// Returns the contents of the currently opened buffer or
/// an empty string if none is open
pub fn current_buffer_contents(&self) -> String {
Expand Down
Loading