diff -urp mutt.patched/curs_lib.c mutt.built/curs_lib.c
--- mutt.patched/curs_lib.c	2005-07-09 16:26:15.000000000 +0200
+++ mutt.built/curs_lib.c	2005-07-10 10:05:37.000000000 +0200
@@ -770,3 +770,40 @@ int mutt_strwidth (const char *s)
   }
   return w;
 }
+
+/*
+ * mutt_strwidthreal is like mutt_strwidth except that it doesn't count
+ * characters that control index coloring. If you're working on strings of the
+ * index display, you must use this function instead of mutt_strwidth().
+ */
+
+int mutt_strwidthreal (const char *s)
+{
+  wchar_t wc;
+  int w;
+  size_t k, n;
+  mbstate_t mbstate;
+
+  if (!s) return 0;
+
+  n = mutt_strlen (s);
+
+  memset (&mbstate, 0, sizeof (mbstate));
+  for (w=0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k)
+  {
+    if (k == (size_t)(-1) || k == (size_t)(-2))
+    {
+      k = (k == (size_t)(-1)) ? 1 : n;
+      wc = replacement_char ();
+    }
+    if (wc == M_SPECIAL_INDEX) {
+      s++;
+      n++;
+    } else {
+      if (!IsWPrint (wc))
+	wc = '?';
+      w += wcwidth (wc);
+    }
+  }
+  return w;
+}
diff -urp mutt.patched/muttlib.c mutt.built/muttlib.c
--- mutt.patched/muttlib.c	2005-07-09 16:25:52.000000000 +0200
+++ mutt.built/muttlib.c	2005-07-10 10:04:04.000000000 +0200
@@ -1026,7 +1026,7 @@ void mutt_FormatString (char *dest,		/* 
 	  count -= col; /* how many columns left on this line */
 	  mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
 	  len = mutt_strlen (buf);
-	  wid = mutt_strwidth (buf);
+	  wid = mutt_strwidthreal (buf);
 	  if (count > wid)
 	  {
 	    count -= wid; /* how many chars to pad */
@@ -1040,7 +1040,7 @@ void mutt_FormatString (char *dest,		/* 
 	  memcpy (wptr, buf, len);
 	  wptr += len;
 	  wlen += len;
-	  col += mutt_strwidth (buf);
+	  col += mutt_strwidthreal (buf);
 	}
 	break; /* skip rest of input */
       }
@@ -1092,7 +1092,7 @@ void mutt_FormatString (char *dest,		/* 
 	memcpy (wptr, buf, len);
 	wptr += len;
 	wlen += len;
-	col += mutt_strwidth (buf);
+	col += mutt_strwidthreal (buf);
       }
     }
     else if (*src == '\\')
diff -urp mutt.patched/protos.h mutt.built/protos.h
--- mutt.patched/protos.h	2005-07-09 16:25:52.000000000 +0200
+++ mutt.built/protos.h	2005-07-09 23:53:35.000000000 +0200
@@ -339,6 +339,7 @@ void _mutt_save_message (HEADER *, CONTE
 int mutt_save_message (HEADER *, int, int, int, int *);
 int mutt_search_command (int, int);
 int mutt_strwidth (const char *);
+int mutt_strwidthreal (const char *);
 int mutt_compose_menu (HEADER *, char *, size_t, HEADER *);
 int mutt_thread_set_flag (HEADER *, int, int, int);
 int mutt_user_is_recipient (HEADER *);

