-+ if ((col < COLS && wlen < destlen) || soft)
- {
-- while (pad--)
-+ int pad;
-+
-+ /* get contents after padding */
-+ mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
-+ len = mutt_strlen (buf);
-+ wid = mutt_strwidth (buf);
-+
-+ /* try to consume as many columns as we can, if we don't have
-+ * memory for that, use as much memory as possible */
-+ pad = (COLS - col - wid) / pw;
-+ if (pad > 0 && wlen + (pad * pl) + len > destlen)
-+ pad = ((signed)(destlen - wlen - len)) / pl;
-+ if (pad > 0)
- {
-- memcpy (wptr, src, pl);
-- wptr += pl;
-- wlen += pl;
-- col += pw;
-+ while (pad--)
-+ {
-+ memcpy (wptr, src, pl);
-+ wptr += pl;
-+ wlen += pl;
-+ col += pw;
-+ }
- }
-+ else if (soft && pad < 0)
-+ {
-+ /* set wptr and wlen back just enough bytes to make sure buf
-+ * fits on screen, \0-terminate dest so mutt_wstr_trunc()
-+ * can correctly compute string's length */
-+ if (pad < -wlen)
-+ pad = -wlen;
-+ *wptr = 0;
-+ wlen = mutt_wstr_trunc (dest, wlen + pad, col + pad, &col);
-+ wptr = dest + wlen;
-+ }
-+ if (len + wlen > destlen)
-+ len = mutt_wstr_trunc (buf, destlen - wlen, COLS - col, NULL);
-+ memcpy (wptr, buf, len);
-+ wptr += len;
-+ wlen += len;
-+ col += wid;
-+ src += pl;
- }
-- else if (soft && pad < 0)