aboutsummaryrefslogtreecommitdiff
path: root/lib/input_screen.ml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/input_screen.ml15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/input_screen.ml b/lib/input_screen.ml
index 3fae53c..45979aa 100644
--- a/lib/input_screen.ml
+++ b/lib/input_screen.ml
@@ -22,12 +22,15 @@ let rec render t ({ user_input; on_enter; on_cancel; screen; prompt } as state)
| `End | `Key (`ASCII 'G', [ `Ctrl ]) | `Key (`ASCII 'C', [ `Ctrl ]) -> on_cancel ()
| `Key (`Enter, []) -> on_enter user_input
| `Key (`Backspace, []) ->
- let state =
- { state with
- user_input = String.sub user_input 0 (max (String.length user_input - 1) 0)
- }
- in
- render t state
+ if String.equal "" user_input
+ then on_cancel ()
+ else (
+ let state =
+ { state with
+ user_input = String.sub user_input 0 (max (String.length user_input - 1) 0)
+ }
+ in
+ render t state)
| `Resize _ -> render t state
| `Key (`ASCII c, []) ->
let state = { state with user_input = user_input ^ String.make 1 c } in