mirror of
https://github.com/ddworken/hishtory.git
synced 2025-03-17 00:38:15 +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`)
|
out = tester.RunInteractiveShell(t, `hishtory query -pipefail`)
|
||||||
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-query")
|
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-query")
|
||||||
out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery SPACE -pipefail ENTER"})
|
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")
|
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-tquery")
|
||||||
|
|
||||||
// And change the config to filter out duplicate rows
|
// And change the config to filter out duplicate rows
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
-pipefail
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Search Query: > -pipefail
|
Search Query: > -pipefail
|
||||||
|
|
||||||
┌───────────────────────────────────────────────────────────────────────────┐
|
┌───────────────────────────────────────────────────────────────────────────┐
|
||||||
|
@ -181,11 +181,12 @@ type bannerMsg struct {
|
|||||||
banner string
|
banner string
|
||||||
}
|
}
|
||||||
type asyncQueryFinishedMsg struct {
|
type asyncQueryFinishedMsg struct {
|
||||||
rows []table.Row
|
rows []table.Row
|
||||||
entries []*data.HistoryEntry
|
entries []*data.HistoryEntry
|
||||||
searchErr error
|
searchErr error
|
||||||
forceUpdateTable bool
|
forceUpdateTable bool
|
||||||
maintainCursor bool
|
maintainCursor bool
|
||||||
|
overriddenSearchQuery *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialModel(ctx context.Context, initialQuery string) model {
|
func initialModel(ctx context.Context, initialQuery string) model {
|
||||||
@ -266,7 +267,7 @@ func runQueryAndUpdateTable(m model, forceUpdateTable, maintainCursor bool) tea.
|
|||||||
}
|
}
|
||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
rows, entries, searchErr := getRows(m.ctx, hctx.GetConf(m.ctx).DisplayedColumns, query, PADDED_NUM_ENTRIES)
|
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
|
return nil
|
||||||
@ -338,6 +339,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
case asyncQueryFinishedMsg:
|
case asyncQueryFinishedMsg:
|
||||||
m = updateTable(m, msg.rows, msg.entries, msg.searchErr, msg.forceUpdateTable, msg.maintainCursor)
|
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
|
return m, nil
|
||||||
default:
|
default:
|
||||||
var cmd tea.Cmd
|
var cmd tea.Cmd
|
||||||
@ -607,7 +611,14 @@ func TuiQuery(ctx context.Context, initialQuery string) error {
|
|||||||
// Async: Get the initial set of rows
|
// Async: Get the initial set of rows
|
||||||
go func() {
|
go func() {
|
||||||
rows, entries, err := getRows(ctx, hctx.GetConf(ctx).DisplayedColumns, initialQuery, PADDED_NUM_ENTRIES)
|
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
|
// Async: Retrieve additional entries from the backend
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user