summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-11 11:39:15 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-11 11:39:51 +0900
commit9030b67e4f80256f91023a01c3fb2bdab060d717 (patch)
tree3290eba3fc909456380bc087da95ad15a2e82bb0
parent43eafdf4b7390242eb0b9391b8586b08c5a518b2 (diff)
downloadfzf-9030b67e4f80256f91023a01c3fb2bdab060d717.tar.gz
Fix window sizing with borders on the right
-rw-r--r--src/terminal.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 4acabf7b..92e01345 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1756,11 +1756,14 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
t.areaLines = height
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
noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode)
if forcePreview || t.needPreviewWindow() {
var resizePreviewWindows func(previewOpts *previewOpts)
- stickToRight := false
resizePreviewWindows = func(previewOpts *previewOpts) {
t.activePreviewOpts = previewOpts
if previewOpts.size.size == 0 {
@@ -1826,11 +1829,9 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
if previewOpts.hidden {
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() &&
- !previewOpts.HasBorderRight() && !t.listBorderShape.HasRight() && !t.inputBorderShape.HasRight() &&
- (!t.headerVisible || !t.headerBorderShape.HasRight() || t.visibleHeaderLines() == 0)
- if stickToRight {
+
+ listStickToRight = listStickToRight && !previewOpts.HasBorderRight()
+ if listStickToRight {
innerWidth++
width++
}
@@ -1903,9 +1904,12 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
innerBorderFn(marginInt[0], marginInt[3]+pwidth, width-pwidth, height)
createPreviewWindow(marginInt[0], marginInt[3], pwidth, height)
} else {
- // NOTE: fzf --preview 'cat {}' --preview-window border-left --border
- stickToRight = !previewOpts.HasBorderRight() && t.borderShape.HasRight()
- if stickToRight {
+ // NOTE: Relaxed condition for the following cases
+ // fzf --preview 'seq 500' --preview-window border-left --border
+ // 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++
width++
}
@@ -1919,7 +1923,7 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
}
resizePreviewWindows(&t.previewOpts)
- if t.borderShape.HasRight() && !stickToRight {
+ if t.borderShape.HasRight() && !listStickToRight {
// 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 up,hidden --bind space:toggle-preview --border vertical
@@ -1942,7 +1946,7 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
// Without preview window
if t.window == nil {
- if t.borderShape.HasRight() && !hasListBorder {
+ if listStickToRight {
// Put scrollbar closer to the right border for consistent look
innerWidth++
width++