Allow preview window height shorter than 3

Fix #2231
This commit is contained in:
Junegunn Choi 2020-11-03 21:49:21 +09:00
parent 1bcbc5a353
commit 2553806e79
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -653,7 +653,7 @@ func (t *Terminal) displayWidth(runes []rune) int {
} }
const ( const (
minWidth = 16 minWidth = 4
minHeight = 4 minHeight = 4
maxDisplayWidthCalc = 1024 maxDisplayWidthCalc = 1024
@ -801,17 +801,19 @@ func (t *Terminal) resizeWindows() {
t.pwindow = t.tui.NewWindow(y, x, pwidth, pheight, true, noBorder) t.pwindow = t.tui.NewWindow(y, x, pwidth, pheight, true, noBorder)
} }
verticalPad := 2 verticalPad := 2
minPreviewHeight := 3
if t.preview.border == tui.BorderNone { if t.preview.border == tui.BorderNone {
verticalPad = 0 verticalPad = 0
minPreviewHeight = 1
} }
switch t.preview.position { switch t.preview.position {
case posUp: case posUp:
pheight := calculateSize(height, t.preview.size, minHeight, 3, verticalPad) pheight := calculateSize(height, t.preview.size, minHeight, minPreviewHeight, verticalPad)
t.window = t.tui.NewWindow( t.window = t.tui.NewWindow(
marginInt[0]+pheight, marginInt[3], width, height-pheight, false, noBorder) marginInt[0]+pheight, marginInt[3], width, height-pheight, false, noBorder)
createPreviewWindow(marginInt[0], marginInt[3], width, pheight) createPreviewWindow(marginInt[0], marginInt[3], width, pheight)
case posDown: case posDown:
pheight := calculateSize(height, t.preview.size, minHeight, 3, verticalPad) pheight := calculateSize(height, t.preview.size, minHeight, minPreviewHeight, verticalPad)
t.window = t.tui.NewWindow( t.window = t.tui.NewWindow(
marginInt[0], marginInt[3], width, height-pheight, false, noBorder) marginInt[0], marginInt[3], width, height-pheight, false, noBorder)
createPreviewWindow(marginInt[0]+height-pheight, marginInt[3], width, pheight) createPreviewWindow(marginInt[0]+height-pheight, marginInt[3], width, pheight)