mirror of
https://github.com/Maks1mS/bubbles.git
synced 2024-12-23 22:32:59 +03:00
Keep y-offset in bounds when setting content
This commit is contained in:
parent
0d5d7e5acd
commit
158097df66
@ -71,6 +71,10 @@ func (m Model) ScrollPercent() float64 {
|
||||
func (m *Model) SetContent(s string) {
|
||||
s = strings.Replace(s, "\r\n", "\n", -1) // normalize line endings
|
||||
m.lines = strings.Split(s, "\n")
|
||||
|
||||
if m.YOffset > len(m.lines)-1 {
|
||||
m.GotoBottom()
|
||||
}
|
||||
}
|
||||
|
||||
// Return the lines that should currently be visible in the viewport.
|
||||
|
Loading…
Reference in New Issue
Block a user