Patch 8.0.1432
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, closes #2541)
Files: src/quickfix.c, src/testdir/test_quickfix.vim
*** ../vim-8.0.1431/src/quickfix.c 2017-12-26 13:53:06.247810065 +0100
--- src/quickfix.c 2018-01-27 11:49:45.014732639 +0100
***************
*** 3421,3427 ****
/*
* Find a window displaying the quickfix/location list 'qi'
! * Searches in only the windows opened in the current tab.
*/
static win_T *
qf_find_win(qf_info_T *qi)
--- 3421,3427 ----
/*
* 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)
***************
*** 3430,3438 ****
FOR_ALL_WINDOWS(win)
if (is_qf_win(win, qi))
! break;
!
! return win;
}
/*
--- 3430,3437 ----
FOR_ALL_WINDOWS(win)
if (is_qf_win(win, qi))
! return win;
! return NULL;
}
/*
***************
*** 4945,4950 ****
--- 4944,4967 ----
}
/*
+ * Return the quickfix/location list window identifier in the current tabpage.
+ */
+ static int
+ qf_winid(qf_info_T *qi)
+ {
+ win_T *win;
+
+ /* 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 = qf_find_win(qi);
+ if (win != NULL)
+ return win->w_id;
+ 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.
***************
*** 5053,5059 ****
if ((status == OK) && (flags & QF_GETLIST_NR))
status = dict_add_nr_str(retdict, "nr", 0L, NULL);
if ((status == OK) && (flags & QF_GETLIST_WINID))
! status = dict_add_nr_str(retdict, "winid", 0L, NULL);
if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
if ((status == OK) && (flags & QF_GETLIST_ID))
--- 5070,5076 ----
if ((status == OK) && (flags & QF_GETLIST_NR))
status = dict_add_nr_str(retdict, "nr", 0L, NULL);
if ((status == OK) && (flags & QF_GETLIST_WINID))
! status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
if ((status == OK) && (flags & QF_GETLIST_ID))
***************
*** 5079,5093 ****
if ((status == OK) && (flags & QF_GETLIST_NR))
status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL);
if ((status == OK) && (flags & QF_GETLIST_WINID))
! {
! win_T *win;
! int win_id = 0;
!
! win = qf_find_win(qi);
! if (win != NULL)
! win_id = win->w_id;
! status = dict_add_nr_str(retdict, "winid", win_id, NULL);
! }
if ((status == OK) && (flags & QF_GETLIST_ITEMS))
{
list_T *l = list_alloc();
--- 5096,5102 ----
if ((status == OK) && (flags & QF_GETLIST_NR))
status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL);
if ((status == OK) && (flags & QF_GETLIST_WINID))
! status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
if ((status == OK) && (flags & QF_GETLIST_ITEMS))
{
list_T *l = list_alloc();
*** ../vim-8.0.1431/src/testdir/test_quickfix.vim 2017-12-26
13:53:06.247810065 +0100
--- src/testdir/test_quickfix.vim 2018-01-27 11:46:52.919875283 +0100
***************
*** 2906,2911 ****
--- 2906,2917 ----
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)
*** ../vim-8.0.1431/src/version.c 2018-01-26 22:22:51.276021100 +0100
--- src/version.c 2018-01-27 11:47:25.711658006 +0100
***************
*** 773,774 ****
--- 773,776 ----
{ /* Add new patch number below this line */
+ /**/
+ 1432,
/**/
--
"Marriage is when a man and woman become as one; the trouble starts
when they try to decide which one"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.