File tree 3 files changed +20
-5
lines changed
3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -36,16 +36,28 @@ type PageLog struct {
36
36
}
37
37
38
38
func (l PageLog ) Render () linebuffer.LineBufferer {
39
+ return l .render (true )
40
+ }
41
+
42
+ func (l PageLog ) RenderWithoutStyle () linebuffer.LineBufferer {
43
+ return l .render (false )
44
+ }
45
+
46
+ func (l PageLog ) render (includeStyle bool ) linebuffer.LineBufferer {
39
47
ts := ""
40
48
if l .CurrentTimestamp != "" {
41
- ts = l .Styles .Green .Render (l .CurrentTimestamp )
49
+ if includeStyle {
50
+ ts = l .Styles .Green .Render (l .CurrentTimestamp )
51
+ } else {
52
+ ts = l .CurrentTimestamp
53
+ }
42
54
}
43
55
label := ""
44
56
if l .CurrentName .ContainerName != "" {
45
57
if ts != "" {
46
58
label += " "
47
59
}
48
- label += l .RenderName (* l .CurrentName , true )
60
+ label += l .RenderName (* l .CurrentName , includeStyle )
49
61
}
50
62
51
63
prefix := ts + label
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ func NewLogsPage(
48
48
Height : height ,
49
49
AllRows : lc .GetOrderedLogs (),
50
50
MatchesFilter : func (log model.PageLog , filter filter.Model ) bool {
51
- return log .Render ().Matches (filter )
51
+ return log .RenderWithoutStyle ().Matches (filter )
52
52
},
53
53
ViewWhenEmpty : "No logs yet" ,
54
54
Styles : styles ,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ type LineBuffer struct {
17
17
lineNoAnsiRuneWidths []uint8 // terminal cell widths
18
18
ansiCodeIndexes [][]uint32 // slice of startByte, endByte indexes of ansi codes
19
19
numNoAnsiRunes int // number of runes in lineNoAnsi
20
+ totalWidth int // total width in terminal cells
20
21
21
22
sparsity int // interval for which to store cumulative cell width
22
23
sparseRuneIdxToNoAnsiByteOffset []uint32 // rune idx to byte offset of lineNoAnsi, stored every sparsity runes
@@ -86,6 +87,9 @@ func New(line string) LineBuffer {
86
87
lb .sparseRuneIdxToNoAnsiByteOffset [runeIdx / lb .sparsity ] = currentOffset
87
88
lb .sparseLineNoAnsiCumRuneWidths [runeIdx / lb .sparsity ] = cumWidth
88
89
}
90
+ if runeIdx == numRunes - 1 {
91
+ lb .totalWidth = int (cumWidth )
92
+ }
89
93
currentOffset += uint32 (runeNumBytes )
90
94
runeIdx ++
91
95
byteOffset += runeNumBytes
@@ -99,8 +103,7 @@ func (l LineBuffer) Width() int {
99
103
if len (l .line ) == 0 {
100
104
return 0
101
105
}
102
- lastRuneIdx := len (l .lineNoAnsiRuneWidths ) - 1
103
- return int (l .getCumulativeWidthAtRuneIdx (lastRuneIdx ))
106
+ return l .totalWidth
104
107
}
105
108
106
109
func (l LineBuffer ) Content () string {
You can’t perform that action at this time.
0 commit comments