Skip to content

Commit

Permalink
Fix line wrapping/padding issue with long lines that have no spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed Nov 24, 2020
1 parent 6ceb358 commit 3d46371
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/line_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static void print_wrap(WINDOW *win, struct line_info *line, int max_x)
}

int space_idx = rspace_index(msg, x_limit - 1);
bool print_padding = false;

if (space_idx >= 1) {
bool newline = print_n_chars(win, msg, space_idx);
Expand All @@ -208,16 +209,20 @@ static void print_wrap(WINDOW *win, struct line_info *line, int max_x)

if (win) {
waddch(win, '\n');

for (size_t i = 0; i < x_start; ++i) {
waddch(win, ' '); // Add padding to the start of the next line
}
print_padding = true;
}
}
} else {
print_n_chars(win, msg, x_limit);
bool newline = print_n_chars(win, msg, x_limit);
msg += x_limit;
length -= x_limit;
print_padding = win != NULL && !newline;
}

if (print_padding) {
for (size_t i = 0; i < x_start; ++i) {
waddch(win, ' '); // Add padding to the start of the next line
}
}
}

Expand Down

0 comments on commit 3d46371

Please sign in to comment.