diff options
author | Jakub Bartodziej | 2021-06-03 13:44:16 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-03 14:23:23 +0000 |
commit | 3c5dfb0633e5e5b64c78cb1c2e96291ef23e08d0 (patch) | |
tree | 0abc42e0512370468f42b1f71e1e0670e2e9268f /helix-term | |
parent | 6cbc0aea926248f029ab3868d5ed9b8d5a4f207f (diff) |
Improve on the fix for deleting from the end of the buffer.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 8d3e31e2..283668cc 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -745,10 +745,6 @@ pub fn extend_line(cx: &mut Context) { // heuristic: append changes to history after each command, unless we're in insert mode fn _delete_selection(doc: &mut Document, view_id: ViewId) { - if doc.empty() { - return; - } - // first yank the selection let values: Vec<String> = doc .selection(view_id) @@ -763,7 +759,11 @@ fn _delete_selection(doc: &mut Document, view_id: ViewId) { // then delete let transaction = Transaction::change_by_selection(doc.text(), doc.selection(view_id), |range| { - (range.from(), range.to() + 1, None) + use std::cmp::{max, min}; + let max_to = max(0, doc.text().len_chars() - 1); + let to = min(max_to, range.to() + 1); + log::info!("{} {} {}", max_to, to, doc.text().len_chars()); + (range.from(), to, None) }); doc.apply(&transaction, view_id); } |