mirror of
https://github.com/ddworken/hishtory.git
synced 2025-03-16 08:18:16 +01:00
Bring back logic that was removed in c9da7a10e4
that made it so invalid initial search queries will get replaced with a query for the empty string
This commit is contained in:
parent
c9da7a10e4
commit
216803f325
@ -2522,7 +2522,7 @@ echo foo`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory query -pipefail`)
|
||||
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-query")
|
||||
out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery SPACE -pipefail ENTER"})
|
||||
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
|
||||
out = strings.TrimSpace(strings.Split(out, "hishtory tquery -pipefail")[1])
|
||||
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-tquery")
|
||||
|
||||
// And change the config to filter out duplicate rows
|
||||
|
@ -1,7 +1,3 @@
|
||||
-pipefail
|
||||
|
||||
|
||||
|
||||
Search Query: > -pipefail
|
||||
|
||||
┌───────────────────────────────────────────────────────────────────────────┐
|
||||
|
@ -181,11 +181,12 @@ type bannerMsg struct {
|
||||
banner string
|
||||
}
|
||||
type asyncQueryFinishedMsg struct {
|
||||
rows []table.Row
|
||||
entries []*data.HistoryEntry
|
||||
searchErr error
|
||||
forceUpdateTable bool
|
||||
maintainCursor bool
|
||||
rows []table.Row
|
||||
entries []*data.HistoryEntry
|
||||
searchErr error
|
||||
forceUpdateTable bool
|
||||
maintainCursor bool
|
||||
overriddenSearchQuery *string
|
||||
}
|
||||
|
||||
func initialModel(ctx context.Context, initialQuery string) model {
|
||||
@ -266,7 +267,7 @@ func runQueryAndUpdateTable(m model, forceUpdateTable, maintainCursor bool) tea.
|
||||
}
|
||||
return func() tea.Msg {
|
||||
rows, entries, searchErr := getRows(m.ctx, hctx.GetConf(m.ctx).DisplayedColumns, query, PADDED_NUM_ENTRIES)
|
||||
return asyncQueryFinishedMsg{rows, entries, searchErr, forceUpdateTable, maintainCursor}
|
||||
return asyncQueryFinishedMsg{rows, entries, searchErr, forceUpdateTable, maintainCursor, nil}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -338,6 +339,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
case asyncQueryFinishedMsg:
|
||||
m = updateTable(m, msg.rows, msg.entries, msg.searchErr, msg.forceUpdateTable, msg.maintainCursor)
|
||||
if msg.overriddenSearchQuery != nil {
|
||||
m.queryInput.SetValue(*msg.overriddenSearchQuery)
|
||||
}
|
||||
return m, nil
|
||||
default:
|
||||
var cmd tea.Cmd
|
||||
@ -607,7 +611,14 @@ func TuiQuery(ctx context.Context, initialQuery string) error {
|
||||
// Async: Get the initial set of rows
|
||||
go func() {
|
||||
rows, entries, err := getRows(ctx, hctx.GetConf(ctx).DisplayedColumns, initialQuery, PADDED_NUM_ENTRIES)
|
||||
p.Send(asyncQueryFinishedMsg{rows: rows, entries: entries, searchErr: err, forceUpdateTable: true, maintainCursor: false})
|
||||
if err == nil || initialQuery == "" {
|
||||
p.Send(asyncQueryFinishedMsg{rows: rows, entries: entries, searchErr: err, forceUpdateTable: true, maintainCursor: false, overriddenSearchQuery: nil})
|
||||
} else {
|
||||
// initialQuery is likely invalid in some way, let's just drop it
|
||||
emptyQuery := ""
|
||||
rows, entries, err := getRows(ctx, hctx.GetConf(ctx).DisplayedColumns, emptyQuery, PADDED_NUM_ENTRIES)
|
||||
p.Send(asyncQueryFinishedMsg{rows: rows, entries: entries, searchErr: err, forceUpdateTable: true, maintainCursor: false, overriddenSearchQuery: &emptyQuery})
|
||||
}
|
||||
}()
|
||||
// Async: Retrieve additional entries from the backend
|
||||
go func() {
|
||||
|
Loading…
Reference in New Issue
Block a user