xA: limit buffer length
Arch Linux AUR Success Details
OpenBSD 7.5 Success Details
Alpine 3.20 Success Details

This commit is contained in:
Přemysl Eric Janouch 2024-11-12 16:19:44 +01:00
parent 3d975c9437
commit 214c349869
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 14 additions and 3 deletions

View File

@ -375,6 +375,17 @@ func bufferToggleUnimportant(name string) {
}, nil) }, nil)
} }
func bufferPushLine(b *buffer, line bufferLine) {
b.lines = append(b.lines, line)
// Fyne's text layouting is extremely slow.
// The limit could be made configurable,
// and we could use a ring buffer approach to storing the lines.
if len(b.lines) > 100 {
b.lines = slices.Delete(b.lines, 0, 1)
}
}
// --- Current buffer ---------------------------------------------------------- // --- Current buffer ----------------------------------------------------------
func bufferToggleLogFinish(err string, response *RelayResponseDataBufferLog) { func bufferToggleLogFinish(err string, response *RelayResponseDataBufferLog) {
@ -755,7 +766,7 @@ func relayProcessBufferLine(b *buffer, m *RelayEventDataBufferLine) {
// Initial sync: skip all other processing, let highlights be. // Initial sync: skip all other processing, let highlights be.
bc := bufferByName(bufferCurrent) bc := bufferByName(bufferCurrent)
if bc == nil { if bc == nil {
b.lines = append(b.lines, line) bufferPushLine(b, line)
return return
} }
@ -767,7 +778,7 @@ func relayProcessBufferLine(b *buffer, m *RelayEventDataBufferLine) {
separate := display && separate := display &&
!visible && bc.newMessages == 0 && bc.newUnimportantMessages == 0 !visible && bc.newMessages == 0 && bc.newUnimportantMessages == 0
b.lines = append(b.lines, line) bufferPushLine(b, line)
if !(visible || m.LeakToActive) || if !(visible || m.LeakToActive) ||
b.newMessages != 0 || b.newUnimportantMessages != 0 { b.newMessages != 0 || b.newUnimportantMessages != 0 {
if line.isUnimportant || m.LeakToActive { if line.isUnimportant || m.LeakToActive {
@ -780,7 +791,7 @@ func relayProcessBufferLine(b *buffer, m *RelayEventDataBufferLine) {
if m.LeakToActive { if m.LeakToActive {
leakedLine := line leakedLine := line
leakedLine.leaked = true leakedLine.leaked = true
bc.lines = append(bc.lines, leakedLine) bufferPushLine(bc, leakedLine)
if !visible || bc.newMessages != 0 || bc.newUnimportantMessages != 0 { if !visible || bc.newMessages != 0 || bc.newUnimportantMessages != 0 {
if line.isUnimportant { if line.isUnimportant {