diff --git a/apps/dog-food/ChatTerminal/Core.hs b/apps/dog-food/ChatTerminal/Core.hs index 24856e498..09d919795 100644 --- a/apps/dog-food/ChatTerminal/Core.hs +++ b/apps/dog-food/ChatTerminal/Core.hs @@ -51,6 +51,9 @@ updateTermState ac tw (key, ms) ts@TerminalState {inputString = s, inputPosition | otherwise -> ts TabKey -> insertCharsWithContact " " BackspaceKey -> backDeleteChar + DeleteKey -> deleteChar + HomeKey -> setPosition 0 + EndKey -> setPosition $ length s ArrowKey d -> case d of Leftwards | ms == mempty -> setPosition $ max 0 (p - 1) @@ -85,10 +88,12 @@ updateTermState ac tw (key, ms) ts@TerminalState {inputString = s, inputPosition Nothing -> "" backDeleteChar | p == 0 || null s = ts - | p >= length s = ts' backDeleteLast - | otherwise = ts' backDelete - backDeleteLast = if null s then (s, 0) else let s' = init s in (s', length s') - backDelete = let (b, a) = splitAt p s in (init b <> a, p - 1) + | p >= length s = ts' (init s, length s - 1) + | otherwise = let (b, a) = splitAt p s in ts' (init b <> a, p - 1) + deleteChar + | p >= length s || null s = ts + | p == 0 = ts' (tail s, 0) + | otherwise = let (b, a) = splitAt p s in ts' (b <> tail a, p) setPosition p' = ts' (s, p') prevWordPos | p == 0 || null s = p