summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-06-20 08:22:58 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-06-20 08:22:58 +0900
commit549ce3cf6c622aad9a2d5ecde491681244327681 (patch)
tree5d896308516386201acd8871b7c2ed53cf1b520c
parent575bc0768c379f4b4dbbf7486634e09158a3b73d (diff)
downloadfzf-549ce3cf6c622aad9a2d5ecde491681244327681.tar.gz
Do not reserve a single column at the end when scrollbar is hidden
Close #4410 Example: fzf --pointer '' --marker '' --no-scrollbar --wrap --wrap-sign ''
-rw-r--r--src/terminal.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 231375ba..cf6bb4b4 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1479,11 +1479,18 @@ func getScrollbar(perLine int, total int, height int, offset int) (int, int) {
return barLength, barStart
}
+func (t *Terminal) barCol() int {
+ if len(t.scrollbar) == 0 && !t.listBorderShape.HasRight() && !t.borderShape.HasRight() && !t.hasPreviewWindowOnRight() {
+ return 0
+ }
+ return 1
+}
+
func (t *Terminal) wrapCols() int {
if !t.wrap {
return 0 // No wrap
}
- return util.Max(t.window.Width()-(t.pointerLen+t.markerLen+1), 1)
+ return util.Max(t.window.Width()-(t.pointerLen+t.markerLen+t.barCol()), 1)
}
func (t *Terminal) clearNumLinesCache() {
@@ -3070,9 +3077,11 @@ func (t *Terminal) printList() {
func (t *Terminal) printBar(lineNum int, forceRedraw bool, barRange [2]int) bool {
hasBar := lineNum >= barRange[0] && lineNum < barRange[1]
if (hasBar != t.prevLines[lineNum].hasBar || forceRedraw) && t.window.Width() > 0 {
- t.move(lineNum, t.window.Width()-1, true)
- if len(t.scrollbar) > 0 && hasBar {
- t.window.CPrint(tui.ColScrollbar, t.scrollbar)
+ if len(t.scrollbar) > 0 {
+ t.move(lineNum, t.window.Width()-1, true)
+ if hasBar {
+ t.window.CPrint(tui.ColScrollbar, t.scrollbar)
+ }
}
}
return hasBar
@@ -3128,7 +3137,7 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
return line + numLines - 1
}
- maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + 1)
+ maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + t.barCol())
postTask := func(lineNum int, width int, wrapped bool, forceRedraw bool) {
width += extraWidth
if (current || selected || alt) && t.highlightLine {
@@ -3447,7 +3456,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
indentSize = preTask(marker)
}
- maxWidth := t.window.Width() - (indentSize + 1)
+ maxWidth := t.window.Width() - (indentSize + t.barCol())
wasWrapped := false
if wrapped {
wrapSign := t.wrapSign
@@ -4539,6 +4548,10 @@ func (t *Terminal) hasPreviewWindow() bool {
return t.pwindow != nil
}
+func (t *Terminal) hasPreviewWindowOnRight() bool {
+ return t.hasPreviewWindow() && t.activePreviewOpts.position == posRight
+}
+
func (t *Terminal) currentItem() *Item {
cnt := t.merger.Length()
if t.cy >= 0 && cnt > 0 && cnt > t.cy {