Merge pull request #4949 from jamessan/vim-7.4.1592

vim-patch:7.4.1592
This commit is contained in:
James McCoy 2016-06-22 22:04:00 -04:00 committed by GitHub
commit dff0dd2611
3 changed files with 51 additions and 17 deletions

View File

@ -1576,14 +1576,23 @@ win_found:
* set b_p_ro flag). */ * set b_p_ro flag). */
if (!can_abandon(curbuf, forceit)) { if (!can_abandon(curbuf, forceit)) {
EMSG(_(e_nowrtmsg)); EMSG(_(e_nowrtmsg));
ok = FALSE; ok = false;
} else } else {
ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
ECMD_HIDE + ECMD_SET_HELP, ECMD_HIDE + ECMD_SET_HELP,
oldwin == curwin ? curwin : NULL); oldwin == curwin ? curwin : NULL);
} else }
ok = buflist_getfile(qf_ptr->qf_fnum, } else {
(linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); ok = buflist_getfile(qf_ptr->qf_fnum, (linenr_T)1,
GETF_SETMARK | GETF_SWITCH, forceit);
if (qi != &ql_info && !win_valid(oldwin)) {
EMSG(_("E924: Current window was closed"));
ok = false;
qi = NULL;
qf_ptr = NULL;
opened_window = false;
}
}
} }
if (ok == OK) { if (ok == OK) {
@ -1663,21 +1672,22 @@ win_found:
msg_scroll = (int)i; msg_scroll = (int)i;
} }
} else { } else {
if (opened_window) if (opened_window) {
win_close(curwin, TRUE); /* Close opened window */ win_close(curwin, true); // Close opened window
if (qf_ptr->qf_fnum != 0) { }
/* if (qf_ptr != NULL && qf_ptr->qf_fnum != 0) {
* Couldn't open file, so put index back where it was. This could // Couldn't open file, so put index back where it was. This could
* happen if the file was readonly and we changed something. // happen if the file was readonly and we changed something.
*/
failed: failed:
qf_ptr = old_qf_ptr; qf_ptr = old_qf_ptr;
qf_index = old_qf_index; qf_index = old_qf_index;
} }
} }
theend: theend:
qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr; if (qi != NULL) {
qi->qf_lists[qi->qf_curlist].qf_index = qf_index; qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr;
qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
}
if (p_swb != old_swb && opened_window) { if (p_swb != old_swb && opened_window) {
/* Restore old 'switchbuf' value, but not when an autocommand or /* Restore old 'switchbuf' value, but not when an autocommand or
* modeline has changed the value. */ * modeline has changed the value. */

View File

@ -100,7 +100,7 @@ static int included_patches[] = {
// 1595 NA // 1595 NA
// 1594 NA // 1594 NA
// 1593 NA // 1593 NA
// 1592, 1592,
// 1591, // 1591,
// 1590, // 1590,
// 1589, // 1589,

View File

@ -258,6 +258,25 @@ describe('helpgrep', function()
\ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750')
endfunction endfunction
function Test_locationlist_curwin_was_closed()
augroup testgroup
au!
autocmd BufReadCmd t call R(expand("<amatch>"))
augroup END
function R(n)
quit
endfunc
new
let q = []
call add(q, {'filename': 't' })
call setloclist(0, q)
call assert_fails('lrewind', 'E924:')
augroup! testgroup
endfunction
]]) ]])
end) end)
@ -315,4 +334,9 @@ describe('helpgrep', function()
execute('copen') execute('copen')
eq(':setqflist()', eval('g:foo')) eq(':setqflist()', eval('g:foo'))
end) end)
it('errors when an autocommand closes the location list\'s window', function()
call('Test_locationlist_curwin_was_closed')
expected_empty()
end)
end) end)