mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 06:18:16 +00:00
vim-patch:8.1.0213: CTRL-W CR does not work properly in a quickfix window
Problem: CTRL-W CR does not work properly in a quickfix window.
Solution: Split the window if needed. (Jason Franklin)
0a08c63da1
This commit is contained in:
@@ -5227,12 +5227,8 @@ static void nv_down(cmdarg_T *cap)
|
||||
cap->arg = FORWARD;
|
||||
nv_page(cap);
|
||||
} else if (bt_quickfix(curbuf) && cap->cmdchar == CAR) {
|
||||
// In a quickfix window a <CR> jumps to the error under the cursor.
|
||||
if (curwin->w_llist_ref == NULL) {
|
||||
do_cmdline_cmd(".cc"); // quickfix window
|
||||
} else {
|
||||
do_cmdline_cmd(".ll"); // location list window
|
||||
}
|
||||
// Quickfix window only: view the result under the cursor.
|
||||
qf_view_result(false);
|
||||
} else {
|
||||
// In the cmdline window a <CR> executes the command.
|
||||
if (cmdwin_type != 0 && cap->cmdchar == CAR) {
|
||||
|
@@ -2845,6 +2845,39 @@ static char_u *qf_types(int c, int nr)
|
||||
return buf;
|
||||
}
|
||||
|
||||
// When "split" is false: Open the entry/result under the cursor.
|
||||
// When "split" is true: Open the entry/result under the cursor in a new window.
|
||||
void qf_view_result(bool split)
|
||||
{
|
||||
qf_info_T *qi = &ql_info;
|
||||
|
||||
if (!bt_quickfix(curbuf)) {
|
||||
return;
|
||||
}
|
||||
if (IS_LL_WINDOW(curwin)) {
|
||||
qi = GET_LOC_LIST(curwin);
|
||||
}
|
||||
if (qi == NULL
|
||||
|| qi->qf_lists[qi->qf_curlist].qf_count == 0) {
|
||||
EMSG(_(e_quickfix));
|
||||
return;
|
||||
}
|
||||
|
||||
if (split) {
|
||||
char cmd[32];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "split +%" PRId64 "%s",
|
||||
(int64_t)curwin->w_cursor.lnum,
|
||||
IS_LL_WINDOW(curwin) ? "ll" : "cc");
|
||||
if (do_cmdline_cmd(cmd) == OK) {
|
||||
do_cmdline_cmd("clearjumps");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
do_cmdline_cmd((IS_LL_WINDOW(curwin) ? ".ll" : ".cc"));
|
||||
}
|
||||
|
||||
/*
|
||||
* ":cwindow": open the quickfix window if we have errors to display,
|
||||
* close it if not.
|
||||
|
@@ -3372,3 +3372,21 @@ func Test_lbuffer_with_bwipe()
|
||||
au!
|
||||
augroup END
|
||||
endfunc
|
||||
|
||||
" Tests for the "CTRL-W <CR>" command.
|
||||
func Xview_result_split_tests(cchar)
|
||||
call s:setup_commands(a:cchar)
|
||||
|
||||
" Test that "CTRL-W <CR>" in a qf/ll window fails with empty list.
|
||||
call g:Xsetlist([])
|
||||
Xopen
|
||||
let l:win_count = winnr('$')
|
||||
call assert_fails('execute "normal! \<C-W>\<CR>"', 'E42')
|
||||
call assert_equal(l:win_count, winnr('$'))
|
||||
Xclose
|
||||
endfunc
|
||||
|
||||
func Test_view_result_split()
|
||||
call Xview_result_split_tests('c')
|
||||
call Xview_result_split_tests('l')
|
||||
endfunc
|
||||
|
@@ -443,17 +443,11 @@ wingotofile:
|
||||
curwin->w_set_curswant = TRUE;
|
||||
break;
|
||||
|
||||
// Quickfix window only: view the result under the cursor in a new split.
|
||||
case K_KENTER:
|
||||
case CAR:
|
||||
/*
|
||||
* In a quickfix window a <CR> jumps to the error under the
|
||||
* cursor in a new window.
|
||||
*/
|
||||
if (bt_quickfix(curbuf)) {
|
||||
sprintf(cbuf, "split +%" PRId64 "%s",
|
||||
(int64_t)curwin->w_cursor.lnum,
|
||||
(curwin->w_llist_ref == NULL) ? "cc" : "ll");
|
||||
do_cmdline_cmd(cbuf);
|
||||
qf_view_result(true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user