]> granicus.if.org Git - neomutt/commitdiff
Fix smart wrap in pager without breaking header
authorAustin Ray <austin.duke.ray@gmail.com>
Sat, 21 Oct 2017 18:08:34 +0000 (14:08 -0400)
committerRichard Russon <rich@flatcap.org>
Wed, 25 Oct 2017 15:51:03 +0000 (16:51 +0100)
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
pager.c

diff --git a/init.h b/init.h
index f22c542ce05b7e62a36283cd2686ab51e4064f01..726d2baca0e35ee9b53a62871d36ca9d1900f520 100644 (file)
--- 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 9508c9d7df024ff1e4b7bfae09ce165376b03029..f337ac69ea3430516ac94869cab6f09202b64104 100644 (file)
--- 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 */