MCPcopy
hub / github.com/derailed/k9s / applyFilter

Method applyFilter

internal/model/log.go:335–362  ·  view source on GitHub ↗
(index int, q string)

Source from the content-addressed store, hash-verified

333}
334
335func (l *Log) applyFilter(index int, q string) ([][]byte, error) {
336 if q == "" {
337 return nil, nil
338 }
339 matches, indices, err := l.lines.Filter(index, q, l.logOptions.ShowTimestamp)
340 if err != nil {
341 return nil, err
342 }
343
344 // No filter!
345 if matches == nil {
346 ll := make([][]byte, l.lines.Len())
347 l.lines.Render(index, l.logOptions.ShowTimestamp, ll)
348 return ll, nil
349 }
350 // Blank filter
351 if len(matches) == 0 {
352 return nil, nil
353 }
354 filtered := make([][]byte, 0, len(matches))
355 ll := make([][]byte, l.lines.Len())
356 l.lines.Lines(index, l.logOptions.ShowTimestamp, ll)
357 for i, idx := range matches {
358 filtered = append(filtered, color.Highlight(ll[idx], indices[i], 209))
359 }
360
361 return filtered, nil
362}
363
364func (l *Log) fireLogBuffChanged(index int) {
365 ll := make([][]byte, l.lines.Len()-index)

Callers 1

fireLogBuffChangedMethod · 0.95

Calls 5

HighlightFunction · 0.92
LinesMethod · 0.80
FilterMethod · 0.65
RenderMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected