summaryrefslogtreecommitdiff
path: root/src/result_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-16 01:38:45 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-16 01:38:45 +0900
commit3e7f032ec200f00f92fa53f9aecde4b989c7dd66 (patch)
tree490418973327dc24fcfd036e14f856a11af183d7 /src/result_test.go
parentb42f5bfb19b080eb12b886ec0787de47a069cc33 (diff)
downloadfzf-3e7f032ec200f00f92fa53f9aecde4b989c7dd66.tar.gz
Allow displaying --nth parts in a different text style
Close #4183
Diffstat (limited to 'src/result_test.go')
-rw-r--r--src/result_test.go42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/result_test.go b/src/result_test.go
index c11e1ab5..520ee4b1 100644
--- a/src/result_test.go
+++ b/src/result_test.go
@@ -131,7 +131,7 @@ func TestColorOffset(t *testing.T) {
colBase := tui.NewColorPair(89, 189, tui.AttrUndefined)
colMatch := tui.NewColorPair(99, 199, tui.AttrUndefined)
- colors := item.colorOffsets(offsets, tui.Dark256, colBase, colMatch, true)
+ colors := item.colorOffsets(offsets, nil, tui.Dark256, colBase, colMatch, tui.AttrUndefined, true)
assert := func(idx int, b int32, e int32, c tui.ColorPair) {
o := colors[idx]
if o.offset[0] != b || o.offset[1] != e || o.color != c {
@@ -155,20 +155,30 @@ func TestColorOffset(t *testing.T) {
colRegular := tui.NewColorPair(-1, -1, tui.AttrUndefined)
colUnderline := tui.NewColorPair(-1, -1, tui.Underline)
- colors = item.colorOffsets(offsets, tui.Dark256, colRegular, colUnderline, true)
- // [{[0 5] {1 5 0}} {[5 15] {1 5 8}} {[15 20] {1 5 0}}
- // {[22 25] {2 6 1}} {[25 27] {2 6 9}} {[27 30] {-1 -1 8}}
- // {[30 32] {3 7 8}} {[32 33] {-1 -1 8}} {[33 35] {4 8 9}}
- // {[35 40] {4 8 1}}]
- assert(0, 0, 5, tui.NewColorPair(1, 5, tui.AttrUndefined))
- assert(1, 5, 15, tui.NewColorPair(1, 5, tui.Underline))
- assert(2, 15, 20, tui.NewColorPair(1, 5, tui.AttrUndefined))
- assert(3, 22, 25, tui.NewColorPair(2, 6, tui.Bold))
- assert(4, 25, 27, tui.NewColorPair(2, 6, tui.Bold|tui.Underline))
- assert(5, 27, 30, colUnderline)
- assert(6, 30, 32, tui.NewColorPair(3, 7, tui.Underline))
- assert(7, 32, 33, colUnderline)
- assert(8, 33, 35, tui.NewColorPair(4, 8, tui.Bold|tui.Underline))
- assert(9, 35, 40, tui.NewColorPair(4, 8, tui.Bold))
+ nthOffsets := []Offset{{37, 39}, {42, 45}}
+ for _, attr := range []tui.Attr{tui.AttrRegular, tui.StrikeThrough} {
+ colors = item.colorOffsets(offsets, nthOffsets, tui.Dark256, colRegular, colUnderline, attr, true)
+
+ // [{[0 5] {1 5 0}} {[5 15] {1 5 8}} {[15 20] {1 5 0}}
+ // {[22 25] {2 6 1}} {[25 27] {2 6 9}} {[27 30] {-1 -1 8}}
+ // {[30 32] {3 7 8}} {[32 33] {-1 -1 8}} {[33 35] {4 8 9}}
+ // {[35 37] {4 8 1}} {[37 39] {4 8 x|1}} {[39 40] {4 8 x|1}}]
+ assert(0, 0, 5, tui.NewColorPair(1, 5, tui.AttrUndefined))
+ assert(1, 5, 15, tui.NewColorPair(1, 5, tui.Underline))
+ assert(2, 15, 20, tui.NewColorPair(1, 5, tui.AttrUndefined))
+ assert(3, 22, 25, tui.NewColorPair(2, 6, tui.Bold))
+ assert(4, 25, 27, tui.NewColorPair(2, 6, tui.Bold|tui.Underline))
+ assert(5, 27, 30, colUnderline)
+ assert(6, 30, 32, tui.NewColorPair(3, 7, tui.Underline))
+ assert(7, 32, 33, colUnderline)
+ assert(8, 33, 35, tui.NewColorPair(4, 8, tui.Bold|tui.Underline))
+ assert(9, 35, 37, tui.NewColorPair(4, 8, tui.Bold))
+ expected := tui.Bold | attr
+ if attr == tui.AttrRegular {
+ expected = tui.AttrRegular
+ }
+ assert(10, 37, 39, tui.NewColorPair(4, 8, expected))
+ assert(11, 39, 40, tui.NewColorPair(4, 8, tui.Bold))
+ }
}