fix backspace key not working when input contains exactly one char
@@ -149,7 +149,6 @@ impl Command {
con: &AppContext,
state: &Box<dyn AppState>,
) {
- let mut handled_by_input_field = false;
debug!("add_event {:?}", event);
match event {
Event::Click(x, y) => {
@@ -215,26 +214,26 @@ impl Command {
return;
}
+ // input field management
+ if input_field.apply_event(&event) {
+ self.raw = input_field.get_content();
+ self.parts = CommandParts::from(&self.raw);
+ self.action = Action::from(&self.parts, false);
+ return;
+ }
+
+ // following handling have the lowest priority
+
if *key == keys::BACKSPACE {
- handled_by_input_field = input_field.apply_event(&event);
- if !handled_by_input_field {
self.action = Action::Back;
return;
}
}
-
- handled_by_input_field = input_field.apply_event(&event);
- }
Event::Wheel(lines_count) => {
self.action = Action::MoveSelection(*lines_count);
}
_ => {}
}
- if handled_by_input_field {
- self.raw = input_field.get_content();
- self.parts = CommandParts::from(&self.raw);
- self.action = Action::from(&self.parts, false);
- }
}
}
