Add control-d as an alternate key binding to close the TUI to fix #61 (plus some tests)

This commit is contained in:
David Dworken 2022-12-18 00:27:29 -08:00
parent d15376f37d
commit 5f95ac48a4
No known key found for this signature in database
3 changed files with 17 additions and 1 deletions

View File

@ -1884,6 +1884,18 @@ func TestTui(t *testing.T) {
})
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
compareGoldens(t, out, "TestTui-LeftScroll")
// Check that we can exit the TUI via pressing esc
out = captureTerminalOutput(t, tester, []string{
"hishtory SPACE tquery ENTER",
"Escape",
})
if strings.Contains(out, "Search Query:") {
t.Fatalf("unexpected out=\n%s", out)
}
if !testutils.IsGithubAction() {
compareGoldens(t, out, "TestTui-Exit")
}
}
func captureTerminalOutput(t *testing.T, tester shellTester, commands []string) string {

View File

@ -0,0 +1,4 @@
/Users/david/.zshrc:source:22: no such file or directory: /usr/share/fzf/key-bindings.zsh
david@Davids-MacBook-Air hishtory % hishtory tquery
david@Davids-MacBook-Air hishtory %

View File

@ -125,7 +125,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "esc", "ctrl+c":
case "esc", "ctrl+c", "ctrl+d":
m.quitting = true
return m, tea.Quit
case "enter":