Skip to content

Commit c1db755

Browse files
committed
Fixed wrapping function when text length = maxchars
1 parent 9bc4d2b commit c1db755

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adafruit_display_text/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def chunks(lst, n):
5353
for part in chunks(w, max_chars - 1):
5454
parts.append("{}-".format(part))
5555
the_lines.extend(parts[:-1])
56+
# Remove the last hyphen on the last chunk
5657
the_line = parts[-1][:-1]
5758
continue
5859

@@ -63,6 +64,9 @@ def chunks(lst, n):
6364
the_line = "" + w
6465
if the_line: # Last line remaining
6566
the_lines.append(the_line)
67+
# Remove any blank lines
68+
while not the_lines[0]:
69+
del the_lines[0]
6670
# Remove first space from first line:
6771
if the_lines[0][0] == " ":
6872
the_lines[0] = the_lines[0][1:]

0 commit comments

Comments
 (0)