fix: do not scroll if width is 0

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2025-01-07 12:50:54 -03:00
parent fa28725f44
commit 36be8b62a6
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ func (m Model) visibleLines() (lines []string) {
lines = m.lines[top:bottom]
}
if m.xOffset == 0 && m.longestLineWidth <= m.Width {
if (m.xOffset == 0 && m.longestLineWidth <= m.Width) || m.Width == 0 {
return lines
}
+2 -2
View File
@@ -208,7 +208,7 @@ func TestVisibleLines(t *testing.T) {
numberOfLines := 10
m := New(10, numberOfLines)
m.lines = defaultList
m.SetContent(strings.Join(defaultList, "\n"))
list := m.visibleLines()
if len(list) != numberOfLines {
@@ -228,7 +228,7 @@ func TestVisibleLines(t *testing.T) {
numberOfLines := 10
m := New(10, numberOfLines)
m.lines = defaultList
m.SetContent(strings.Join(defaultList, "\n"))
m.YOffset = 5
list := m.visibleLines()