mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-24 22:11:40 +02:00
Add control-d as an alternate key binding to close the TUI to fix #61 (plus some tests)
This commit is contained in:
parent
d15376f37d
commit
5f95ac48a4
@ -1884,6 +1884,18 @@ func TestTui(t *testing.T) {
|
|||||||
})
|
})
|
||||||
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
|
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
|
||||||
compareGoldens(t, out, "TestTui-LeftScroll")
|
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 {
|
func captureTerminalOutput(t *testing.T, tester shellTester, commands []string) string {
|
||||||
|
4
client/lib/goldens/TestTui-Exit
Normal file
4
client/lib/goldens/TestTui-Exit
Normal 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 %
|
@ -125,7 +125,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch msg.String() {
|
switch msg.String() {
|
||||||
case "esc", "ctrl+c":
|
case "esc", "ctrl+c", "ctrl+d":
|
||||||
m.quitting = true
|
m.quitting = true
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
case "enter":
|
case "enter":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user