Skip to content

Commit

Permalink
fix: first line not wrapping correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Aug 23, 2024
1 parent 33d6e80 commit bfdb7c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
23 changes: 23 additions & 0 deletions pkg/emu/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,26 @@ func TestGetLines(t *testing.T) {
require.Equal(t, "foobar", lines[0].String())
require.Equal(t, "baz", lines[1].String())
}

func TestBrokenLine(t *testing.T) {
term := New()
term.Write([]byte(LineFeedMode))

setup := []string{
"> ", "command\n",
}

bigWrite := ""
for row := 0; row < geom.DEFAULT_SIZE.R*2; row++ {
bigWrite += "foo\n"
}
setup = append(setup, bigWrite)
setup = append(setup, "> ")

for _, item := range setup {
term.Write([]byte(item))
}

lines := term.GetLines(0, 0)
require.Equal(t, "> command", lines[0].String())
}
8 changes: 1 addition & 7 deletions pkg/emu/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,8 @@ func isWrappedLines(lines []Line) bool {
}

func appendWrapped(lines []Line, line Line) []Line {
// TODO(cfoust): 05/13/24 test this?
if len(lines) == 0 {
return append(lines, copyLine(line))
}

cloned := getOccupiedLine(copyLine(line))

if !isWrappedLines(lines) {
if len(lines) == 0 || !isWrappedLines(lines) {
return append(lines, cloned)
}

Expand Down

0 comments on commit bfdb7c8

Please sign in to comment.