aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2019-05-03 17:32:01 +0200
committerMarco Hinz <mh.codebro@gmail.com>2019-05-04 01:40:11 +0200
commit06b70bf1d68a9d022d8eb6db41184c7bd930a5b5 (patch)
treeff79e64223010293550b5f8a20a6dfbcd01468bf /src
parentdc5f4a3cc2f7f02e1ff4ec2f67eda4fb73e7d89c (diff)
downloadrneovim-06b70bf1d68a9d022d8eb6db41184c7bd930a5b5.tar.gz
rneovim-06b70bf1d68a9d022d8eb6db41184c7bd930a5b5.tar.bz2
rneovim-06b70bf1d68a9d022d8eb6db41184c7bd930a5b5.zip
vim-patch:8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Problem: After ":copen" can't get the window-ID of the quickfix window. (FalacerSelene) Solution: Make it work without a quickfix list. Add a test. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/2ec364e94dbc080ccdf6c5dfc6f1653b5b7ded64
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c28
-rw-r--r--src/nvim/testdir/test_quickfix.vim6
2 files changed, 25 insertions, 9 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 448b363a86..f9882e9561 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2979,10 +2979,8 @@ static int is_qf_win(win_T *win, qf_info_T *qi)
return FALSE;
}
-/*
- * Find a window displaying the quickfix/location list 'qi'
- * Searches in only the windows opened in the current tab.
- */
+/// Find a window displaying the quickfix/location list 'qi'
+/// Only searches in the current tabpage.
static win_T *qf_find_win(qf_info_T *qi)
{
FOR_ALL_WINDOWS_IN_TAB(win, curtab) {
@@ -4328,6 +4326,21 @@ static int qf_id2nr(const qf_info_T *const qi, const unsigned qfid)
return -1;
}
+/// Return the quickfix/location list window identifier in the current tabpage.
+static int qf_winid(qf_info_T *qi)
+{
+ // The quickfix window can be opened even if the quickfix list is not set
+ // using ":copen". This is not true for location lists.
+ if (qi == NULL) {
+ return 0;
+ }
+ win_T *win = qf_find_win(qi);
+ if (win != NULL) {
+ return win->handle;
+ }
+ return 0;
+}
+
/// Return quickfix/location list details (title) as a
/// dictionary. 'what' contains the details to return. If 'list_idx' is -1,
/// then current list is used. Otherwise the specified list is used.
@@ -4430,7 +4443,7 @@ int qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
status = tv_dict_add_nr(retdict, S_LEN("nr"), 0);
}
if ((status == OK) && (flags & QF_GETLIST_WINID)) {
- status = tv_dict_add_nr(retdict, S_LEN("winid"), 0);
+ status = tv_dict_add_nr(retdict, S_LEN("winid"), qf_winid(qi));
}
if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) {
status = tv_dict_add_str(retdict, S_LEN("context"), (const char *)"");
@@ -4461,10 +4474,7 @@ int qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
status = tv_dict_add_nr(retdict, S_LEN("nr"), qf_idx + 1);
}
if ((status == OK) && (flags & QF_GETLIST_WINID)) {
- win_T *win = qf_find_win(qi);
- if (win != NULL) {
- status = tv_dict_add_nr(retdict, S_LEN("winid"), win->handle);
- }
+ status = tv_dict_add_nr(retdict, S_LEN("winid"), qf_winid(qi));
}
if ((status == OK) && (flags & QF_GETLIST_ITEMS)) {
list_T *l = tv_list_alloc(kListLenMayKnow);
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 0f88f41678..9e5c3ec5f5 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -2859,6 +2859,12 @@ func Xgetlist_empty_tests(cchar)
call assert_equal(0, g:Xgetlist({'changedtick' : 0}).changedtick)
call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, 'changedtick': 0}, g:Xgetlist({'all' : 0}))
+ " Quickfix window with empty stack
+ silent! Xopen
+ let qfwinid = (a:cchar == 'c') ? win_getid() : 0
+ call assert_equal(qfwinid, g:Xgetlist({'winid' : 0}).winid)
+ Xclose
+
" Empty quickfix list
Xexpr ""
call assert_equal('', g:Xgetlist({'context' : 0}).context)