mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-08 00:48:37 +08:00
Compute separator length once in printInfoImpl
separatorLength now derives value from window layout on each call; hoist to local as it cannot change within single repaint
This commit is contained in:
+6
-5
@@ -3398,6 +3398,7 @@ func (t *Terminal) printInfoImpl() {
|
|||||||
}
|
}
|
||||||
pos := 0
|
pos := 0
|
||||||
line := 0
|
line := 0
|
||||||
|
separatorLen := t.separatorLength()
|
||||||
maxHeight := t.window.Height()
|
maxHeight := t.window.Height()
|
||||||
move := func(y int, x int, clear bool) bool {
|
move := func(y int, x int, clear bool) bool {
|
||||||
if y < 0 || y >= maxHeight {
|
if y < 0 || y >= maxHeight {
|
||||||
@@ -3425,7 +3426,7 @@ func (t *Terminal) printInfoImpl() {
|
|||||||
str = string(trimmed)
|
str = string(trimmed)
|
||||||
width = maxWidth
|
width = maxWidth
|
||||||
}
|
}
|
||||||
move(line, pos, t.separatorLength() == 0)
|
move(line, pos, separatorLen == 0)
|
||||||
if t.reading {
|
if t.reading {
|
||||||
t.window.CPrint(tui.ColSpinner, str)
|
t.window.CPrint(tui.ColSpinner, str)
|
||||||
} else {
|
} else {
|
||||||
@@ -3434,7 +3435,7 @@ func (t *Terminal) printInfoImpl() {
|
|||||||
pos += width
|
pos += width
|
||||||
}
|
}
|
||||||
printSeparator := func(fillLength int, pad bool) {
|
printSeparator := func(fillLength int, pad bool) {
|
||||||
if t.separatorLength() > 0 {
|
if separatorLen > 0 {
|
||||||
t.separator(t.window, fillLength)
|
t.separator(t.window, fillLength)
|
||||||
t.window.Print(" ")
|
t.window.Print(" ")
|
||||||
} else if pad {
|
} else if pad {
|
||||||
@@ -3443,7 +3444,7 @@ func (t *Terminal) printInfoImpl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if t.infoStyle == infoHidden {
|
if t.infoStyle == infoHidden {
|
||||||
if t.separatorLength() > 0 {
|
if separatorLen > 0 {
|
||||||
if !move(line+1, 0, false) {
|
if !move(line+1, 0, false) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -3506,7 +3507,7 @@ func (t *Terminal) printInfoImpl() {
|
|||||||
}
|
}
|
||||||
switch t.infoStyle {
|
switch t.infoStyle {
|
||||||
case infoDefault:
|
case infoDefault:
|
||||||
if !move(line+1, 0, t.separatorLength() == 0) {
|
if !move(line+1, 0, separatorLen == 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
printSpinner()
|
printSpinner()
|
||||||
@@ -3590,7 +3591,7 @@ func (t *Terminal) printInfoImpl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if t.infoStyle == infoInlineRight {
|
if t.infoStyle == infoInlineRight {
|
||||||
if t.separatorLength() > 0 {
|
if separatorLen > 0 {
|
||||||
if !move(line+1, 0, false) {
|
if !move(line+1, 0, false) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user