mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
Guard View.LinesHeight against a concurrent write
The count comes from the view's buffer, which a rendering task appends to on its own goroutine, so reading it without the write mutex is a data race. Nobody called it until now, which is why nothing has tripped over it; the next commit does, from the UI thread while a render is still loading. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ad3a337675
commit
a0b9ca978c
@@ -2063,6 +2063,9 @@ func (v *View) ViewBufferLines() []string {
|
||||
|
||||
// LinesHeight is the count of view lines (i.e. lines excluding wrapping)
|
||||
func (v *View) LinesHeight() int {
|
||||
v.writeMutex.Lock()
|
||||
defer v.writeMutex.Unlock()
|
||||
|
||||
return len(v.buf.lines)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user