Skip to content

Commit 4b6c079

Browse files
committed
Account for padding when wrapping lines
You can check for one-off errors with the following command: $ alias wash-colors="sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g'" $ ./4cli | head -n 3000 | wash-colors | grep ".\{81,\}" It should only show lines with a very long word (e.g. links), and text that is not printed by 'print_post_contents' (e.g. thread titles).
1 parent c47d14e commit 4b6c079

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/pretty.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ static void print_post_contents(FILE* fp, const char* str, bool use_pad) {
162162
/* Position in the string of the last printed newline or space */
163163
size_t last_newline_idx = 0, last_space_idx = 0;
164164

165+
size_t max_column = MAX_COLUMN;
166+
if (use_pad)
167+
max_column -= POST_PAD;
168+
165169
size_t i;
166170
for (i = 0; str[i] != '\0'; i++) {
167171
/*
@@ -181,8 +185,7 @@ static void print_post_contents(FILE* fp, const char* str, bool use_pad) {
181185
const bool is_first_word_of_input_line =
182186
(last_space_idx == 0 || str[last_space_idx] == '\n');
183187

184-
/* TODO: Check one-off errors */
185-
if (i - last_newline_idx >= MAX_COLUMN) {
188+
if (i - last_newline_idx >= max_column) {
186189
fputc('\n', fp);
187190
last_newline_idx = last_space_idx;
188191
if (use_pad)

0 commit comments

Comments
 (0)