vim-patch:8.0.0762: ml_get error with :psearch in buffer without a name

Problem:    ml_get error with :psearch in buffer without a name. (Dominique
            Pelle)
Solution:   Use the buffer number instead of the file name.  Check the cursor
            position.
c31f9ae4f1
This commit is contained in:
Jan Edmund Lazo 2018-08-18 21:47:45 -04:00
parent 98632f1cce
commit 098e1f9dfd
3 changed files with 16 additions and 1 deletions

View File

@ -4603,7 +4603,7 @@ search_line:
if (depth == -1) { if (depth == -1) {
// match in current file // match in current file
if (l_g_do_tagpreview != 0) { if (l_g_do_tagpreview != 0) {
if (!GETFILE_SUCCESS(getfile(0, curwin_save->w_buffer->b_fname, if (!GETFILE_SUCCESS(getfile(curwin_save->w_buffer->b_fnum, NULL,
NULL, true, lnum, false))) { NULL, true, lnum, false))) {
break; // failed to jump to file break; // failed to jump to file
} }
@ -4611,6 +4611,7 @@ search_line:
setpcmark(); setpcmark();
} }
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;
check_cursor();
} else { } else {
if (!GETFILE_SUCCESS(getfile(0, files[depth].name, NULL, true, if (!GETFILE_SUCCESS(getfile(0, files[depth].name, NULL, true,
files[depth].lnum, false))) { files[depth].lnum, false))) {

View File

@ -88,6 +88,7 @@ NEW_TESTS ?= \
test_normal.res \ test_normal.res \
test_number.res \ test_number.res \
test_options.res \ test_options.res \
test_preview.res \
test_profile.res \ test_profile.res \
test_put.res \ test_put.res \
test_python2.res \ test_python2.res \

View File

@ -0,0 +1,13 @@
" Tests for the preview window
func Test_Psearch()
" this used to cause ml_get errors
help
let wincount = winnr('$')
0f
ps.
call assert_equal(wincount + 1, winnr('$'))
pclose
call assert_equal(wincount, winnr('$'))
bwipe
endfunc