mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-01 20:52:06 -07:00
Fix highlight offsets of multi-line entries
Fix regression from 4811e52a
This commit is contained in:
@@ -278,6 +278,7 @@ func extractColor(str string, state *ansiState, proc func(string, *ansiState) bo
|
|||||||
|
|
||||||
if code == "\n" {
|
if code == "\n" {
|
||||||
output.WriteRune('\n')
|
output.WriteRune('\n')
|
||||||
|
runeCount++
|
||||||
// Full-background marker
|
// Full-background marker
|
||||||
if newState.lbg >= 0 {
|
if newState.lbg >= 0 {
|
||||||
marker := newState
|
marker := newState
|
||||||
|
@@ -81,7 +81,7 @@ func Run(opts *Options) (int, error) {
|
|||||||
lineAnsiState = newState
|
lineAnsiState = newState
|
||||||
|
|
||||||
// Full line background is found. Add a special marker.
|
// Full line background is found. Add a special marker.
|
||||||
if !opts.ReadZero && offsets != nil && newState != nil && len(*offsets) > 0 && newState.lbg >= 0 {
|
if offsets != nil && newState != nil && len(*offsets) > 0 && newState.lbg >= 0 {
|
||||||
marker := (*offsets)[len(*offsets)-1]
|
marker := (*offsets)[len(*offsets)-1]
|
||||||
marker.offset[0] = marker.offset[1]
|
marker.offset[0] = marker.offset[1]
|
||||||
marker.color.bg = newState.lbg
|
marker.color.bg = newState.lbg
|
||||||
|
@@ -3399,13 +3399,8 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
|||||||
finalLineNum = lineNum
|
finalLineNum = lineNum
|
||||||
offsets := []colorOffset{}
|
offsets := []colorOffset{}
|
||||||
lbg := tui.NoColorPair()
|
lbg := tui.NoColorPair()
|
||||||
var lineLen int
|
|
||||||
for idx, offset := range allOffsets {
|
for idx, offset := range allOffsets {
|
||||||
lineLen = len(line)
|
lineEnd := int32(from + len(line))
|
||||||
if lineLen > 0 && line[lineLen-1] == '\n' {
|
|
||||||
lineLen--
|
|
||||||
}
|
|
||||||
lineEnd := int32(from + lineLen)
|
|
||||||
if offset.offset[0] >= lineEnd {
|
if offset.offset[0] >= lineEnd {
|
||||||
if offset.IsFullBgMarker(lineEnd) {
|
if offset.IsFullBgMarker(lineEnd) {
|
||||||
lbg = offset.color
|
lbg = offset.color
|
||||||
@@ -3441,7 +3436,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
from += lineLen
|
from += len(line)
|
||||||
if lineOffset < skipLines {
|
if lineOffset < skipLines {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user