mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
fix: do not navigate out to the right
This commit is contained in:
@@ -331,9 +331,23 @@ func (m *Model) MoveLeft() {
|
||||
|
||||
// MoveRight moves all lines to set runes right.
|
||||
func (m *Model) MoveRight() {
|
||||
// prevents over scrolling to the right
|
||||
if m.indent >= m.longestLineWidth()-m.Width {
|
||||
return
|
||||
}
|
||||
m.indent += m.horizontalStep
|
||||
}
|
||||
|
||||
func (m Model) longestLineWidth() int {
|
||||
w := 0
|
||||
for _, l := range m.lines {
|
||||
if ww := ansi.StringWidth(l); ww > w {
|
||||
w = ww
|
||||
}
|
||||
}
|
||||
return w
|
||||
}
|
||||
|
||||
// Resets lines indent to zero.
|
||||
func (m *Model) ResetIndent() {
|
||||
m.indent = 0
|
||||
|
||||
Reference in New Issue
Block a user