m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-14 22:33:47 -05:00

Fix window sizing with borders on the right

This commit is contained in:
Junegunn Choi
2025-01-11 11:39:15 +09:00
parent 43eafdf4b7
commit 9030b67e4f

View File

@@ -1756,11 +1756,14 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
t.areaLines = height t.areaLines = height
t.areaColumns = width t.areaColumns = width
// If none of the inner borders has the right side, but the outer border does, increase the list width by 1 column
listStickToRight := t.borderShape.HasRight() && !t.listBorderShape.HasRight() && !t.inputBorderShape.HasRight() &&
(!t.headerVisible || !t.headerBorderShape.HasRight() || t.visibleHeaderLines() == 0)
// Set up preview window // Set up preview window
noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode) noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode)
if forcePreview || t.needPreviewWindow() { if forcePreview || t.needPreviewWindow() {
var resizePreviewWindows func(previewOpts *previewOpts) var resizePreviewWindows func(previewOpts *previewOpts)
stickToRight := false
resizePreviewWindows = func(previewOpts *previewOpts) { resizePreviewWindows = func(previewOpts *previewOpts) {
t.activePreviewOpts = previewOpts t.activePreviewOpts = previewOpts
if previewOpts.size.size == 0 { if previewOpts.size.size == 0 {
@@ -1826,11 +1829,9 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
if previewOpts.hidden { if previewOpts.hidden {
return return
} }
// If none of the inner borders has the right side, but the outer border does, increase the width by 1 column
stickToRight = t.borderShape.HasRight() && listStickToRight = listStickToRight && !previewOpts.HasBorderRight()
!previewOpts.HasBorderRight() && !t.listBorderShape.HasRight() && !t.inputBorderShape.HasRight() && if listStickToRight {
(!t.headerVisible || !t.headerBorderShape.HasRight() || t.visibleHeaderLines() == 0)
if stickToRight {
innerWidth++ innerWidth++
width++ width++
} }
@@ -1903,9 +1904,12 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
innerBorderFn(marginInt[0], marginInt[3]+pwidth, width-pwidth, height) innerBorderFn(marginInt[0], marginInt[3]+pwidth, width-pwidth, height)
createPreviewWindow(marginInt[0], marginInt[3], pwidth, height) createPreviewWindow(marginInt[0], marginInt[3], pwidth, height)
} else { } else {
// NOTE: fzf --preview 'cat {}' --preview-window border-left --border // NOTE: Relaxed condition for the following cases
stickToRight = !previewOpts.HasBorderRight() && t.borderShape.HasRight() // fzf --preview 'seq 500' --preview-window border-left --border
if stickToRight { // fzf --preview 'seq 500' --preview-window border-left --border --list-border
// fzf --preview 'seq 500' --preview-window border-left --border --input-border
listStickToRight = t.borderShape.HasRight() && !previewOpts.HasBorderRight()
if listStickToRight {
innerWidth++ innerWidth++
width++ width++
} }
@@ -1919,7 +1923,7 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
} }
resizePreviewWindows(&t.previewOpts) resizePreviewWindows(&t.previewOpts)
if t.borderShape.HasRight() && !stickToRight { if t.borderShape.HasRight() && !listStickToRight {
// Need to clear the extra margin between the borders // Need to clear the extra margin between the borders
// fzf --preview 'seq 1000' --preview-window border-left --bind space:change-preview-window:border-rounded --border vertical // fzf --preview 'seq 1000' --preview-window border-left --bind space:change-preview-window:border-rounded --border vertical
// fzf --preview 'seq 1000' --preview-window up,hidden --bind space:toggle-preview --border vertical // fzf --preview 'seq 1000' --preview-window up,hidden --bind space:toggle-preview --border vertical
@@ -1942,7 +1946,7 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
// Without preview window // Without preview window
if t.window == nil { if t.window == nil {
if t.borderShape.HasRight() && !hasListBorder { if listStickToRight {
// Put scrollbar closer to the right border for consistent look // Put scrollbar closer to the right border for consistent look
innerWidth++ innerWidth++
width++ width++