mirror of
https://github.com/ddworken/hishtory.git
synced 2025-03-31 19:37:34 +02:00
Make the query input box in the TUI match the terminal dimensions
This commit is contained in:
parent
30ba0bd35c
commit
48e33d5034
@ -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)
|
||||
}
|
||||
|
15
client/lib/goldens/TestTui-LongQuery
Normal file
15
client/lib/goldens/TestTui-LongQuery
Normal file
@ -0,0 +1,15 @@
|
||||
Search Query: > 1234567890qwertyuip1234567890qwertyuip1234567890qwertyuip1234567890qwertyuip12345678
|
||||
|
||||
┌───────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Hostname CWD Timestamp Runtime Exit Code Command │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
└───────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
hiSHtory: Search your shell history • ctrl+h help
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user