b9b9176
			   READLINE PATCH REPORT
b9b9176
			   =====================
b9b9176
b9b9176
Readline-Release: 5.2
b9b9176
Patch-ID: readline52-004
b9b9176
b9b9176
Bug-Reported-by: Peter Volkov <torre_cremata@mail.ru>
b9b9176
Bug-Reference-ID: <1173636022.7039.36.camel@localhost>
b9b9176
Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2007-03/msg00039.html
b9b9176
b9b9176
Bug-Description:
b9b9176
b9b9176
When restoring the original prompt after finishing an incremental search,
b9b9176
bash sometimes places the cursor incorrectly if the primary prompt contains
b9b9176
invisible characters.
b9b9176
b9b9176
Patch:
b9b9176
b9b9176
*** ../readline-5.2.3/display.c	Fri Apr 20 13:30:16 2007
b9b9176
--- display.c	Fri Apr 20 15:17:01 2007
b9b9176
***************
b9b9176
*** 1599,1604 ****
b9b9176
  	  if (temp > 0)
b9b9176
  	    {
b9b9176
  	      _rl_output_some_chars (nfd, temp);
b9b9176
! 	      _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
b9b9176
  	    }
b9b9176
  	}
b9b9176
--- 1599,1618 ----
b9b9176
  	  if (temp > 0)
b9b9176
  	    {
b9b9176
+ 	      /* If nfd begins at the prompt, or before the invisible
b9b9176
+ 		 characters in the prompt, we need to adjust _rl_last_c_pos
b9b9176
+ 		 in a multibyte locale to account for the wrap offset and
b9b9176
+ 		 set cpos_adjusted accordingly. */
b9b9176
  	      _rl_output_some_chars (nfd, temp);
b9b9176
! 	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
b9b9176
! 		{
b9b9176
!                   _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
b9b9176
!                   if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
b9b9176
! 		    {
b9b9176
! 		      _rl_last_c_pos -= wrap_offset;
b9b9176
! 		      cpos_adjusted = 1;
b9b9176
! 		    }
b9b9176
! 		}
b9b9176
!               else
b9b9176
!                 _rl_last_c_pos += temp;
b9b9176
  	    }
b9b9176
  	}
b9b9176
***************
b9b9176
*** 1608,1613 ****
b9b9176
--- 1622,1639 ----
b9b9176
  	  if (temp > 0)
b9b9176
  	    {
b9b9176
+ 	      /* If nfd begins at the prompt, or before the invisible
b9b9176
+ 		 characters in the prompt, we need to adjust _rl_last_c_pos
b9b9176
+ 		 in a multibyte locale to account for the wrap offset and
b9b9176
+ 		 set cpos_adjusted accordingly. */
b9b9176
  	      _rl_output_some_chars (nfd, temp);
b9b9176
  	      _rl_last_c_pos += col_temp;		/* XXX */
b9b9176
+ 	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
b9b9176
+ 		{
b9b9176
+ 		  if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
b9b9176
+ 		    {
b9b9176
+ 		      _rl_last_c_pos -= wrap_offset;
b9b9176
+ 		      cpos_adjusted = 1;
b9b9176
+ 		    }
b9b9176
+ 		}
b9b9176
  	    }
b9b9176
  	  lendiff = (oe - old) - (ne - new);