Skip to content
Myr

fix(filter): wide chars

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Carlos Alexandro Becker · committed by Carlos Alexandro Becker · parent d3d20ef · Browse files · 1 file+5 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Diff stats

1 file+5 added−8 removed

  • other:+5 added−8 removed

1 file+5 added−8 removed

modified:filter/filter.go+5 added-8 removed
209 unmodified lines
210 s.WriteRune('\n')211 continue212 }213214 // Use ansi.Truncate and ansi.TruncateLeft and ansi.StringWidth to215 // style match.MatchedIndexes without losing the original option style:214 var buf strings.Builder215 lastIdx := 0216217 // Use ansi.Truncate and ansi.TruncateLeft and ansi.StringWidth to218 // style match.MatchedIndexes without losing the original option style:219 for _, rng := range matchedRanges(match.MatchedIndexes) {220 // fmt.Print("here ", lastIdx, rng, " - ", match.Str[rng[0]:rng[1]+1], "\r\n")221 // Add the text before this match222 if rng[0] > lastIdx {223 buf.WriteString(ansi.Cut(styledOption, lastIdx, rng[0]))224 }225226 // Add the matched character with highlight226 buf.WriteString(m.matchStyle.Render(match.Str[rng[0] : rng[1]+1]))227 buf.WriteString(m.matchStyle.Render(ansi.Cut(match.Str, rng[0], rng[1]+1)))228 lastIdx = rng[1] + 1229 }230231 // Add any remaining text after the last match231 // fmt.Print("here ", lastIdx, ansi.StringWidth(styledOption), len(match.Str), "\r\n")232 if lastIdx < ansi.StringWidth(styledOption) {233 remaining := ansi.TruncateLeft(styledOption, lastIdx, "")234 buf.WriteString(remaining)235 }232 buf.WriteString(ansi.TruncateLeft(styledOption, lastIdx, ""))233234 // Flush text buffer.235 s.WriteString(lineTextStyle.Render(buf.String()))236
306 unmodified lines