From 66dbee10f56ba3d776ad176b603eee9f30f0e940 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 12 Nov 2024 17:36:12 +0100 Subject: [PATCH] Fix minimum preview width without left/right borders When the chosen preview border shape has no left and/or right border, the minimum total preview window size decreases. But due to the hardcoded value for the minimum size of the preview window the size could not be decreased further than 5. --- src/terminal.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/terminal.go b/src/terminal.go index 467682a9..23e9767f 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -1679,7 +1679,13 @@ func (t *Terminal) resizeWindows(forcePreview bool) { createPreviewWindow(marginInt[0]+height-pheight, marginInt[3], width, pheight) } case posLeft, posRight: - pwidth := calculateSize(width, previewOpts.size, minWidth, 5, 4) + pad := borderColumns(previewOpts.border, t.borderWidth) + if len(t.scrollbar) > 0 && !previewOpts.border.HasRight() { + // Need a column to show scrollbar + pad += 1 + } + minPreviewWidth := 1 + pad + pwidth := calculateSize(width, previewOpts.size, minWidth, minPreviewWidth, pad) if hasThreshold && pwidth < previewOpts.threshold { t.activePreviewOpts = previewOpts.alternative if forcePreview { @@ -1718,9 +1724,6 @@ func (t *Terminal) resizeWindows(forcePreview bool) { marginInt[0], marginInt[3], width-pwidth, height, false, noBorder) // NOTE: fzf --preview 'cat {}' --preview-window border-left --border x := marginInt[3] + width - pwidth - if !previewOpts.border.HasRight() && t.borderShape.HasRight() { - pwidth++ - } createPreviewWindow(marginInt[0], x, pwidth, height) } }