Skip to content

Commit

Permalink
trim trailing space from log content
Browse files Browse the repository at this point in the history
  • Loading branch information
robinovitch61 committed Feb 1, 2025
1 parent 647d303 commit 255fc83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/model/k8s_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/robinovitch61/kl/internal/viewport/linebuffer"
"strings"
"time"
"unicode"
)

type Log struct {
Expand Down Expand Up @@ -58,6 +59,7 @@ func (ls LogScanner) StartReadingLogs() {

logContent := strings.Join(vals[1:], " ")
logContent = strings.ReplaceAll(logContent, "\t", " ")
logContent = strings.TrimRightFunc(logContent, unicode.IsSpace)

// precompute LogData here as logs come in as logs are immutable. Having the LogData up front helps
// to minimize expensive/repeated re-computation later
Expand Down
4 changes: 2 additions & 2 deletions internal/viewport/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ func (m Model[T]) getVisibleContentLines() visibleContentLinesResult {
}

if m.wrapText {
lb := currItem.Render() // TODO LEO: strings.TrimRightFunc(currItem.String(), unicode.IsSpace), m.width
lb := currItem.Render()
itemLines := lb.WrappedLines(m.width, m.height, m.stringToHighlight, m.highlightStyle(currItemIdx))
offsetLines := safeSliceFromIdx(itemLines, m.topItemLineOffset)
done = addLines(linebuffer.ToLineBuffers(offsetLines), currItemIdx)
Expand All @@ -728,7 +728,7 @@ func (m Model[T]) getVisibleContentLines() visibleContentLinesResult {
done = true
} else {
currItem = m.allItems[currItemIdx]
lb = currItem.Render() // TODO LEO: strings.TrimRightFunc(currItem.String(), unicode.IsSpace), m.width
lb = currItem.Render()
itemLines = lb.WrappedLines(m.width, m.height, m.stringToHighlight, m.highlightStyle(currItemIdx))
done = addLines(linebuffer.ToLineBuffers(itemLines), currItemIdx)
}
Expand Down

0 comments on commit 255fc83

Please sign in to comment.