changeset: 7182:4240966d41fc
user:      Kevin McCarthy <[email protected]>
date:      Wed Nov 15 14:53:19 2017 -0800
link:      http://dev.mutt.org/hg/mutt/rev/4240966d41fc

Fix $smart_wrap to not be disabled by whitespace-prefixed lines. (closes #3857)

changeset:737102af74eb fixed a folded header display issue with $smart_wrap
by disabling $smart_wrap for lines beginning with whitespace.

Unfortunately, this turns off smart wrapping in the body of an email
too, even when the line has other whitespace breaks in it.

An earlier commit, changeset:125076e0fdfa added an infinite loop fix
when MUTT_PAGER_NSKIP is set, by disabling the smart_wrap if the space
backtracking went to the beginning of the line.  That is, a line
beginning with 1+ whitespace followed by a single long word.

Extend this second commit by always disabling the smart_wrap in that
case, not just when MUTT_PAGER_NSKIP is set.  This also solves the
folded header issue without other side effects.

changeset: 7183:2ff00d88bcf6
user:      Kevin McCarthy <[email protected]>
date:      Wed Nov 15 14:53:24 2017 -0800
link:      http://dev.mutt.org/hg/mutt/rev/2ff00d88bcf6

Remove useless else branch in the $smart_wrap code. (see #3857)

Thanks to Vincent Lefèvre for noticing the nested else was redundant,
since buf_ptr is already set to "buf + cnt" after the format_line()
call.

This allows us to merge the inner and outer if statement, resulting in
simpler code.

diffs (42 lines):

diff -r 8a41d1c2f267 -r 2ff00d88bcf6 pager.c
--- a/pager.c   Sat Nov 11 15:49:15 2017 -0800
+++ b/pager.c   Wed Nov 15 14:53:24 2017 -0800
@@ -1462,23 +1462,23 @@
   /* move the break point only if smart_wrap is set */
   if (option (OPTWRAP))
   {
-    if (cnt < b_read)
+    if (cnt < b_read &&
+        ch != -1 &&
+        buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] != 
'\r')
     {
-      if (ch != -1 && buf[0] != ' ' && buf[0] != '\t' &&
-         buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] 
!= '\r')
-      {
-       buf_ptr = buf + ch;
-       /* skip trailing blanks */
-       while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r'))
-         ch--;
-        /* a very long word with leading spaces causes infinite wrapping */
-        if ((!ch) && (flags & MUTT_PAGER_NSKIP))
-          buf_ptr = buf + cnt;
-        else
-          cnt = ch + 1;
-      }
+      buf_ptr = buf + ch;
+      /* skip trailing blanks */
+      while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r'))
+        ch--;
+      /* A very long word with leading spaces causes infinite
+       * wrapping when MUTT_PAGER_NSKIP is set.  A folded header
+       * with a single long word shouldn't be smartwrapped
+       * either.  So just disable smart_wrap if it would wrap at the
+       * beginning of the line. */
+      if (!ch)
+        buf_ptr = buf + cnt;
       else
-       buf_ptr = buf + cnt; /* a very long word... */
+        cnt = ch + 1;
     }
     if (!(flags & MUTT_PAGER_NSKIP))
       /* skip leading blanks on the next line too */

Reply via email to