Make sure preview command is not run before Terminal is ready

This commit is contained in:
Junegunn Choi 2024-08-11 14:48:52 +09:00
parent a2d0e8f233
commit e28f5aa45b
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -382,6 +382,7 @@ const (
reqRedrawPreviewLabel
reqClose
reqPrintQuery
reqPreviewReady
reqPreviewEnqueue
reqPreviewDisplay
reqPreviewRefresh
@ -3469,6 +3470,7 @@ func (t *Terminal) Loop() error {
go func() {
var version int64
stop := false
t.previewBox.WaitFor(reqPreviewReady)
for {
var items []*Item
var commandTemplate string
@ -3497,6 +3499,9 @@ func (t *Terminal) Loop() error {
if stop {
break
}
if items == nil {
continue
}
version++
// We don't display preview window if no match
if items[0] != nil {
@ -3738,6 +3743,9 @@ func (t *Terminal) Loop() error {
t.printHeader()
case reqActivate:
t.suppress = false
if t.hasPreviewer() {
t.previewBox.Set(reqPreviewReady, nil)
}
case reqRedrawBorderLabel:
t.printLabel(t.border, t.borderLabel, t.borderLabelOpts, t.borderLabelLen, t.borderShape, true)
case reqRedrawPreviewLabel: