Add test for quoting dashes

This commit is contained in:
David Dworken 2024-09-15 21:19:41 -07:00
parent df2be5cfe2
commit 7550310167
No known key found for this signature in database
2 changed files with 9 additions and 3 deletions

View File

@ -2114,6 +2114,14 @@ func testTui_search(t *testing.T, onlineStatus OnlineStatus) {
"'\"'foo:bar'\"'",
}))
testutils.CompareGoldens(t, out, "TestTui-SearchColonDoubleQuoted")
// And check that we can quote dashes
require.NoError(t, db.Create(testutils.MakeFakeHistoryEntry("foo --bar")).Error)
out = stripTuiCommandPrefix(t, captureTerminalOutput(t, tester, []string{
"hishtory SPACE tquery ENTER",
"'\"'--bar'\"'",
}))
testutils.CompareGoldens(t, out, "TestTui-SearchQuoteDash")
}
func testTui_general(t *testing.T, onlineStatus OnlineStatus) {

View File

@ -995,9 +995,7 @@ func splitEscaped(query string, separator rune, maxSplit int) []string {
token = append(token, runeQuery[i])
}
}
if string(token) != "" {
tokens = append(tokens, string(token))
}
tokens = append(tokens, string(token))
return tokens
}