mirror of
https://github.com/junegunn/fzf.git
synced 2026-04-29 02:24:42 +08:00
Fix --preview-window follow not working correctly with wrapping
Fix #3243 Fix #4258
This commit is contained in:
+4
-2
@@ -1423,8 +1423,10 @@ func (w *LightWindow) fill(str string, resetCode string) FillReturn {
|
||||
for i, line := range allLines {
|
||||
lines := WrapLine(line, w.posx, w.width, w.tabstop, w.wrapSignWidth)
|
||||
for j, wl := range lines {
|
||||
w.stderrInternal(wl.Text, false, resetCode)
|
||||
w.posx += wl.DisplayWidth
|
||||
if w.posx < w.width {
|
||||
w.stderrInternal(wl.Text, false, resetCode)
|
||||
w.posx += wl.DisplayWidth
|
||||
}
|
||||
|
||||
// Wrap line
|
||||
if j < len(lines)-1 || i < len(allLines)-1 {
|
||||
|
||||
+3
-1
@@ -971,7 +971,9 @@ func (w *TcellWindow) fillString(text string, pair ColorPair) FillReturn {
|
||||
w.renderWrapSign(style)
|
||||
}
|
||||
}
|
||||
w.renderGraphemes(wl.Text, style)
|
||||
if w.lastX < w.width {
|
||||
w.renderGraphemes(wl.Text, style)
|
||||
}
|
||||
}
|
||||
}
|
||||
if w.lastX >= w.width {
|
||||
|
||||
+4
-3
@@ -1377,7 +1377,8 @@ func WrapLine(input string, prefixLength int, initialMax int, tabstop int, wrapS
|
||||
width := 0
|
||||
line := ""
|
||||
gr := uniseg.NewGraphemes(input)
|
||||
max := initialMax
|
||||
maxWidth := initialMax
|
||||
contMax := max(1, initialMax-wrapSignWidth)
|
||||
for gr.Next() {
|
||||
rs := gr.Runes()
|
||||
str := string(rs)
|
||||
@@ -1392,14 +1393,14 @@ func WrapLine(input string, prefixLength int, initialMax int, tabstop int, wrapS
|
||||
}
|
||||
width += w
|
||||
|
||||
if prefixLength+width <= max {
|
||||
if prefixLength+width <= maxWidth {
|
||||
line += str
|
||||
} else {
|
||||
lines = append(lines, WrappedLine{string(line), width - w})
|
||||
line = str
|
||||
prefixLength = 0
|
||||
width = w
|
||||
max = initialMax - wrapSignWidth
|
||||
maxWidth = contMax
|
||||
}
|
||||
}
|
||||
lines = append(lines, WrappedLine{string(line), width})
|
||||
|
||||
Reference in New Issue
Block a user