Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
patch 8.2.3489: ml_get error after search with range
Problem:    ml_get error after search with range.
Solution:   Limit the line number to the buffer line count.
  • Loading branch information
brammool committed Oct 9, 2021
1 parent 26190b2 commit 35a319b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ex_docmd.c
Expand Up @@ -4229,8 +4229,10 @@ get_address(

// When '/' or '?' follows another address, start from
// there.
if (lnum != MAXLNUM)
curwin->w_cursor.lnum = lnum;
if (lnum > 0 && lnum != MAXLNUM)
curwin->w_cursor.lnum =
lnum > curbuf->b_ml.ml_line_count
? curbuf->b_ml.ml_line_count : lnum;

// Start a forward search at the end of the line (unless
// before the first line).
Expand Down
14 changes: 14 additions & 0 deletions src/testdir/test_search.vim
Expand Up @@ -1989,5 +1989,19 @@ func Test_no_last_search_pattern()
call feedkeys("??\<C-T>", 'xt')
endfunc

func Test_search_with_invalid_range()
new
let lines =<< trim END
/\%.v
5/
c
END
call writefile(lines, 'Xrangesearch')
source Xrangesearch

bwipe!
call delete('Xrangesearch')
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -757,6 +757,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3489,
/**/
3488,
/**/
Expand Down

0 comments on commit 35a319b

Please sign in to comment.