Disable deleting from an empty buffer which can cause a crash.

pull/95/head
Jakub Bartodziej 3 years ago committed by Blaž Hrastnik
parent c1c3750d38
commit 6cbc0aea92

@ -745,6 +745,10 @@ 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)

@ -494,6 +494,10 @@ impl Document {
pub fn versioned_identifier(&self) -> lsp::VersionedTextDocumentIdentifier {
lsp::VersionedTextDocumentIdentifier::new(self.url().unwrap(), self.version)
}
pub fn empty(&self) -> bool {
self.text == "\n"
}
}
#[cfg(test)]

Loading…
Cancel
Save