diff --git a/client/client_test.go b/client/client_test.go index 88c164c..d641208 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -1805,6 +1805,14 @@ func testTui_resize(t testing.TB) { }) require.Contains(t, out, "\necho 'aaaaaa bbbb'\n") + // Check that it supports a very long search query + out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []TmuxCommand{ + {Keys: "hishtory SPACE tquery ENTER"}, + {Keys: "1234567890qwertyuip1234567890qwertyuip1234567890qwertyuip1234567890qwertyuip1234567890qwertyuip"}, + }) + out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1]) + testutils.CompareGoldens(t, out, "TestTui-LongQuery") + // Assert there are no leaked connections assertNoLeakedConnections(t) } diff --git a/client/lib/goldens/TestTui-LongQuery b/client/lib/goldens/TestTui-LongQuery new file mode 100644 index 0000000..435d176 --- /dev/null +++ b/client/lib/goldens/TestTui-LongQuery @@ -0,0 +1,15 @@ +Search Query: > 1234567890qwertyuip1234567890qwertyuip1234567890qwertyuip1234567890qwertyuip12345678 + +┌───────────────────────────────────────────────────────────────────────────────────────────┐ +│ Hostname CWD Timestamp Runtime Exit Code Command │ +│───────────────────────────────────────────────────────────────────────────────────────────│ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└───────────────────────────────────────────────────────────────────────────────────────────┘ +hiSHtory: Search your shell history • ctrl+h help \ No newline at end of file diff --git a/client/tui/tui.go b/client/tui/tui.go index f366c6b..6a64be4 100644 --- a/client/tui/tui.go +++ b/client/tui/tui.go @@ -195,9 +195,14 @@ func initialModel(ctx context.Context, t table.Model, tableEntries []*data.Histo queryInput := textinput.New() queryInput.Placeholder = "ls" queryInput.Focus() - queryInput.CharLimit = 156 - // TODO: Make the width of the query input match the width of the terminal - queryInput.Width = 50 + queryInput.CharLimit = 200 + width, _, err := getTerminalSize() + if err == nil { + queryInput.Width = width + } else { + hctx.GetLogger().Infof("getTerminalSize() return err=%#v, defaulting queryInput to a width of 50", err) + queryInput.Width = 50 + } if initialQuery != "" { queryInput.SetValue(initialQuery) } @@ -307,6 +312,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } case tea.WindowSizeMsg: m.help.Width = msg.Width + m.queryInput.Width = msg.Width cmd := runQueryAndUpdateTable(m, true, true) return m, cmd case offlineMsg: