File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4521,13 +4521,14 @@ get_address(
45214521 if (lnum != MAXLNUM )
45224522 curwin -> w_cursor .lnum = lnum ;
45234523 /*
4524- * Start a forward search at the end of the line.
4524+ * Start a forward search at the end of the line (unless
4525+ * before the first line).
45254526 * Start a backward search at the start of the line.
45264527 * This makes sure we never match in the current
45274528 * line, and can match anywhere in the
45284529 * next/previous line.
45294530 */
4530- if (c == '/' )
4531+ if (c == '/' && curwin -> w_cursor . lnum > 0 )
45314532 curwin -> w_cursor .col = MAXCOL ;
45324533 else
45334534 curwin -> w_cursor .col = 0 ;
Original file line number Diff line number Diff line change @@ -2650,8 +2650,12 @@ del_lines(
26502650 int
26512651gchar_pos (pos_T * pos )
26522652{
2653- char_u * ptr = ml_get_pos ( pos ) ;
2653+ char_u * ptr ;
26542654
2655+ /* When searching columns is sometimes put at the end of a line. */
2656+ if (pos -> col == MAXCOL )
2657+ return NUL ;
2658+ ptr = ml_get_pos (pos );
26552659#ifdef FEAT_MBYTE
26562660 if (has_mbyte )
26572661 return (* mb_ptr2char )(ptr );
Original file line number Diff line number Diff line change @@ -348,24 +348,29 @@ inc_cursor(void)
348348 int
349349inc (pos_T * lp )
350350{
351- char_u * p = ml_get_pos ( lp ) ;
351+ char_u * p ;
352352
353- if (* p != NUL ) /* still within line, move to next char (may be NUL) */
353+ /* when searching position may be set to end of a line */
354+ if (lp -> col != MAXCOL )
354355 {
355- #ifdef FEAT_MBYTE
356- if (has_mbyte )
356+ p = ml_get_pos ( lp );
357+ if (* p != NUL ) /* still within line, move to next char (may be NUL) */
357358 {
358- int l = (* mb_ptr2len )(p );
359+ #ifdef FEAT_MBYTE
360+ if (has_mbyte )
361+ {
362+ int l = (* mb_ptr2len )(p );
359363
360- lp -> col += l ;
361- return ((p [l ] != NUL ) ? 0 : 2 );
362- }
364+ lp -> col += l ;
365+ return ((p [l ] != NUL ) ? 0 : 2 );
366+ }
363367#endif
364- lp -> col ++ ;
368+ lp -> col ++ ;
365369#ifdef FEAT_VIRTUALEDIT
366- lp -> coladd = 0 ;
370+ lp -> coladd = 0 ;
367371#endif
368- return ((p [1 ] != NUL ) ? 0 : 2 );
372+ return ((p [1 ] != NUL ) ? 0 : 2 );
373+ }
369374 }
370375 if (lp -> lnum != curbuf -> b_ml .ml_line_count ) /* there is a next line */
371376 {
Original file line number Diff line number Diff line change @@ -729,3 +729,10 @@ func Test_look_behind()
729729 call search (getline (" ." ))
730730 bwipe!
731731endfunc
732+
733+ func Test_search_sentence ()
734+ new
735+ " this used to cause a crash
736+ call assert_fails (" /\\ %'" , ' E486' )
737+ call assert_fails (" /" , ' E486' )
738+ endfunc
Original file line number Diff line number Diff line change @@ -771,6 +771,8 @@ static char *(features[]) =
771771
772772static int included_patches [] =
773773{ /* Add new patch number below this line */
774+ /**/
775+ 1416 ,
774776/**/
775777 1415 ,
776778/**/
You can’t perform that action at this time.
0 commit comments