From b1d18dffae2bcda3e948d048b7a05be6ec15b8a4 Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Fri, 4 Oct 2024 14:11:06 +0100 Subject: [PATCH] pkg/cli/tk: Fix combobox rendering for empty search. Co-authored-by: Michael Penick --- pkg/cli/tk/combobox.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/cli/tk/combobox.go b/pkg/cli/tk/combobox.go index 47b90b467..e75f6a126 100644 --- a/pkg/cli/tk/combobox.go +++ b/pkg/cli/tk/combobox.go @@ -50,7 +50,13 @@ func (w *comboBox) Render(width, height int) *term.Buffer { // TODO: Test the behavior of Render when height is very small // (https://b.elv.sh/1820) if height == 1 { - return w.listBox.Render(width, height) + // This could be caused by either the listbox being empty, or the + // terminal actually being very short. + if w.listBox.CopyState().Items.Len() == 0 { + return w.codeArea.Render(width, height) + } else { + return w.listBox.Render(width, height) + } } buf := w.codeArea.Render(width, height-1) bufListBox := w.listBox.Render(width, height-len(buf.Lines))