on master help sign in
Disable deleting from an empty buffer which can cause a crash.
6cbc0aeJakub Bartodziej
helix-term/src/commands.rs+4
@@ -745,6 +745,10 @@ pub fn extend_line(cx: &mut Context) {
745// heuristic: append changes to history after each command, unless we're in insert mode
745// heuristic: append changes to history after each command, unless we're in insert mode
746
746
747fn _delete_selection(doc: &mut Document, view_id: ViewId) {
747fn _delete_selection(doc: &mut Document, view_id: ViewId) {
748+ if doc.empty() {
749+ return;
750+ }
751+
748 // first yank the selection
752 // first yank the selection
749 let values: Vec<String> = doc
753 let values: Vec<String> = doc
750 .selection(view_id)
754 .selection(view_id)
helix-view/src/document.rs+4
@@ -494,6 +494,10 @@ impl Document {
494 pub fn versioned_identifier(&self) -> lsp::VersionedTextDocumentIdentifier {
494 pub fn versioned_identifier(&self) -> lsp::VersionedTextDocumentIdentifier {
495 lsp::VersionedTextDocumentIdentifier::new(self.url().unwrap(), self.version)
495 lsp::VersionedTextDocumentIdentifier::new(self.url().unwrap(), self.version)
496 }
496 }
497+
498+ pub fn empty(&self) -> bool {
499+ self.text == "\n"
500+ }
497}
501}
498
502
499#[cfg(test)]
503#[cfg(test)]