Fix failing test case

This commit is contained in:
Junegunn Choi 2022-07-20 12:29:45 +09:00
parent 82b46726fc
commit 821fc9feed
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 7 additions and 6 deletions

View File

@ -1247,6 +1247,7 @@ func parsePreviewWindow(opts *previewOpts, input string) {
if len(alternative) > 0 { if len(alternative) > 0 {
alternativeOpts := *opts alternativeOpts := *opts
opts.alternative = &alternativeOpts opts.alternative = &alternativeOpts
opts.alternative.hidden = false
opts.alternative.alternative = nil opts.alternative.alternative = nil
parsePreviewWindow(opts.alternative, alternative) parsePreviewWindow(opts.alternative, alternative)
} }

View File

@ -877,9 +877,6 @@ func (t *Terminal) resizeWindows() {
if previewVisible { if previewVisible {
var resizePreviewWindows func(previewOpts previewOpts) var resizePreviewWindows func(previewOpts previewOpts)
resizePreviewWindows = func(previewOpts previewOpts) { resizePreviewWindows = func(previewOpts previewOpts) {
if previewOpts.hidden {
return
}
hasThreshold := previewOpts.threshold > 0 && previewOpts.alternative != nil hasThreshold := previewOpts.threshold > 0 && previewOpts.alternative != nil
createPreviewWindow := func(y int, x int, w int, h int) { createPreviewWindow := func(y int, x int, w int, h int) {
pwidth := w pwidth := w
@ -930,7 +927,9 @@ func (t *Terminal) resizeWindows() {
case posUp, posDown: case posUp, posDown:
pheight := calculateSize(height, previewOpts.size, minHeight, minPreviewHeight, verticalPad) pheight := calculateSize(height, previewOpts.size, minHeight, minPreviewHeight, verticalPad)
if hasThreshold && pheight < previewOpts.threshold { if hasThreshold && pheight < previewOpts.threshold {
resizePreviewWindows(*previewOpts.alternative) if !previewOpts.alternative.hidden {
resizePreviewWindows(*previewOpts.alternative)
}
return return
} }
if previewOpts.position == posUp { if previewOpts.position == posUp {
@ -945,8 +944,9 @@ func (t *Terminal) resizeWindows() {
case posLeft, posRight: case posLeft, posRight:
pwidth := calculateSize(width, previewOpts.size, minWidth, 5, 4) pwidth := calculateSize(width, previewOpts.size, minWidth, 5, 4)
if hasThreshold && pwidth < previewOpts.threshold { if hasThreshold && pwidth < previewOpts.threshold {
fmt.Println("Alternative", (*previewOpts.alternative).position == posDown) if !previewOpts.alternative.hidden {
resizePreviewWindows(*previewOpts.alternative) resizePreviewWindows(*previewOpts.alternative)
}
return return
} }
if previewOpts.position == posLeft { if previewOpts.position == posLeft {