From 3564579bb150419518dedc305bcdd4bd98ac098a Mon Sep 17 00:00:00 2001 From: Austin Ray Date: Sat, 21 Oct 2017 14:08:34 -0400 Subject: [PATCH] Fix smart wrap in pager without breaking header This commit addresses the issue of smart wrap not working if a line started with whitespace. This behavior was a result commit f5e472b where smart wrap was disabled on lines beginning with a space or tab to prevent headers from having weird wrapping. This commit addresses this issue by only applying smart wrapping if the pager is displaying a message body. This allows smart_wrap to work inside of a message and preserves what commit f5e472b addressed. Additionally, the buf[cnt] checks have been simplified with the use of the ISSPACE() macro. While fixing the smart wrap, it became apparent that the HEADER portion of the pager was not properly updating when the wrap size was modified. To address this, the wrap command was changed from R_PAGER to R_PAGER_FLOW in init.h. This redraws the pager after wrap is modified. --- init.h | 2 +- pager.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/init.h b/init.h index f22c542ce..726d2baca 100644 --- a/init.h +++ b/init.h @@ -4319,7 +4319,7 @@ struct Option MuttVars[] = { ** When \fIset\fP, NeoMutt will weed headers when displaying, forwarding, ** printing, or replying to messages. */ - { "wrap", DT_NUMBER, R_PAGER, UL &Wrap, 0 }, + { "wrap", DT_NUMBER, R_PAGER_FLOW, UL &Wrap, 0 }, /* ** .pp ** When set to a positive value, NeoMutt will wrap text at $$wrap characters. diff --git a/pager.c b/pager.c index 9508c9d7d..f337ac69e 100644 --- a/pager.c +++ b/pager.c @@ -1562,8 +1562,8 @@ static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info, { if (cnt < b_read) { - if (ch != -1 && buf[0] != ' ' && buf[0] != '\t' && buf[cnt] != ' ' && - buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] != '\r') + /* Wrap if the line is not part of the header and buf[cnt] is not whitespace */ + if (ch != -1 && !ISHEADER((*line_info)[n].type) && !ISSPACE(buf[cnt])) { buf_ptr = buf + ch; /* skip trailing blanks */ -- 2.40.0