Skip to content

Commit

Permalink
Fixed array out of bonds after first tail selection
Browse files Browse the repository at this point in the history
  • Loading branch information
aurc committed Aug 1, 2022
1 parent 776f698 commit 0faa0c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/loggo/log_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (l *LogView) makeUIComponents() {
logView: l,
}
selection := func(row, column int) {
if row > 0 {
if row > 0 && row-1 < len(l.finSlice) {
l.jsonView = NewJsonView(l.app, false,
func() {
// Toggle full screen func
Expand All @@ -124,10 +124,10 @@ func (l *LogView) makeUIComponents() {
}, l.makeLayouts)
l.jsonView.SetBorder(true).SetTitle("Log Entry")
var b []byte
if _, ok := l.inSlice[row-1][config.ParseErr]; ok {
b = []byte(fmt.Sprintf(`%v`, l.inSlice[row-1][config.TextPayload]))
if _, ok := l.finSlice[row-1][config.ParseErr]; ok {
b = []byte(fmt.Sprintf(`%v`, l.finSlice[row-1][config.TextPayload]))
} else {
b, _ = json.Marshal(l.inSlice[row-1])
b, _ = json.Marshal(l.finSlice[row-1])
}
l.jsonView.SetJson(b)
l.makeLayoutsWithJsonView()
Expand Down
2 changes: 2 additions & 0 deletions internal/loggo/log_view_readers.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func (l *LogView) sampleAndCount() {
}

func (l *LogView) filterLine(e *filter.Expression, index int) error {
l.filterLock.Lock()
defer l.filterLock.Unlock()
row := l.inSlice[index]
if e == nil {
l.finSlice = append(l.finSlice, row)
Expand Down

0 comments on commit 0faa0c0

Please sign in to comment.