Disable deleting from an empty buffer which can cause a crash.
commit6cbc0aea926248f029ab3868d5ed9b8d5a4f207f
authorJakub Bartodziej <jqb@google.com>
dateThu 3 Jun 2021, 08:51 (5 years ago)
parentc1c3750
helix-term/src/commands.rs+4
@@ -745,6 +745,10 @@ pub fn extend_line(cx: &mut Context) {
745745// heuristic: append changes to history after each command, unless we're in insert mode
746746
747747fn _delete_selection(doc: &mut Document, view_id: ViewId) {
748+ if doc.empty() {
749+ return;
750+ }
751+
748752 // first yank the selection
749753 let values: Vec<String> = doc
750754 .selection(view_id)
helix-view/src/document.rs+4
@@ -494,6 +494,10 @@ impl Document {
494494 pub fn versioned_identifier(&self) -> lsp::VersionedTextDocumentIdentifier {
495495 lsp::VersionedTextDocumentIdentifier::new(self.url().unwrap(), self.version)
496496 }
497+
498+ pub fn empty(&self) -> bool {
499+ self.text == "\n"
500+ }
497501}
498502
499503#[cfg(test)]