feat: make backspace command support not closing the input when value is empty

This commit is contained in:
XYenon 2024-09-25 21:33:02 +08:00
parent 631afd09ee
commit e416e1c434
2 changed files with 1 additions and 5 deletions

View file

@ -232,7 +232,7 @@ keymap = [
{ on = "<End>", run = "move 999", desc = "Move to the EOL" },
# Delete
{ on = "<Backspace>", run = "backspace", desc = "Delete the character before the cursor" },
{ on = "<Backspace>", run = "backspace", desc = "Delete the character before the cursor" },
{ on = "<Delete>", run = "backspace --under", desc = "Delete the character under the cursor" },
{ on = "<C-h>", run = "backspace", desc = "Delete the character before the cursor" },
{ on = "<C-d>", run = "backspace --under", desc = "Delete the character under the cursor" },

View file

@ -16,10 +16,6 @@ impl From<bool> for Opt {
impl Input {
pub fn backspace(&mut self, opt: impl Into<Opt>) {
let snap = self.snaps.current_mut();
if snap.value.is_empty() {
return self.close(false);
}
let opt = opt.into() as Opt;
if !opt.under && snap.cursor < 1 {
return;