Fix bug where typing 'foo:' and then hitting backspace would lead to the error still being displayed

This commit is contained in:
David Dworken 2023-02-19 22:08:38 -08:00
parent 091f37e4a2
commit b69788967f
No known key found for this signature in database
3 changed files with 36 additions and 2 deletions

View File

@ -1839,7 +1839,7 @@ func TestTui(t *testing.T) {
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
testutils.CompareGoldens(t, out, "TestTui-InitialInvalidSearch")
// Check the output when the initial search is invalid
// Check the output when the search is invalid
out = captureTerminalOutput(t, tester, []string{
"hishtory SPACE tquery ENTER",
"ls:",
@ -1847,6 +1847,14 @@ func TestTui(t *testing.T) {
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
testutils.CompareGoldens(t, out, "TestTui-InvalidSearch")
// Check the output when the search is invalid and then edited to become valid
out = captureTerminalOutput(t, tester, []string{
"hishtory SPACE tquery ENTER",
"ls: BSpace",
})
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
testutils.CompareGoldens(t, out, "TestTui-InvalidSearchBecomesValid")
// Check the output when the size is smaller
out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []TmuxCommand{
{Keys: "hishtory SPACE tquery ENTER"},

View File

@ -0,0 +1,26 @@
Search Query: > ls
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ localhost /tmp/ Oct 17 2022 21:43:16 PDT 3s 2 ls ~/ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘

View File

@ -94,7 +94,7 @@ func (m model) Init() tea.Cmd {
}
func runQueryAndUpdateTable(m model, updateTable bool) model {
if (m.runQuery != nil && *m.runQuery != m.lastQuery) || updateTable {
if (m.runQuery != nil && *m.runQuery != m.lastQuery) || updateTable || m.searchErr != nil {
if m.runQuery == nil {
m.runQuery = &m.lastQuery
}