From 6d35093b6caf4bc6eadefe016d43c40e2ff0e002 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sun, 14 May 2023 19:41:41 +0200 Subject: [PATCH] refactor: enter fires query, "o" opens a datasheet This will help make the searching more useful since firing a slow query on an incomplete search term will be no bueno. So, we let the user hit Enter and confirm a search query when doing content queries. --- gshmm.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gshmm.go b/gshmm.go index facc08e..e0fd981 100644 --- a/gshmm.go +++ b/gshmm.go @@ -218,8 +218,8 @@ func filterDatasheetContents(m model) []string { // wait for datasheetsLoaded to go true // then iterate m.datasheets and index them // - // for this function, catch 3 chars or more in the textinput - // start the query, fire the spinner and block any other queries + // for this function, wait until Enter is hit to fire the query, + // run the query, fire the spinner and block any other queries // coming in. return the list hits that come back from the query return []string{} } @@ -294,7 +294,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Quit case "tab": m.toggleFilterMode() - case "enter": + case "o": selectedDatasheet := m.datasheets[len(m.datasheets)-1] // TODO: handle error _ = xdg.Open(selectedDatasheet.absPath) @@ -336,7 +336,7 @@ func (m model) View() string { } body.WriteString("\n" + mode) - help := "[ctrl-c]: quit | [tab]: filter mode | [enter]: open" + help := "[ctrl-c]: quit | [tab]: filter mode | [o]: open" body.WriteString("\n" + help) return body.String()