Hi,
On Wed, Jan 10, 2018 at 3:45 AM, FalacerSelene
<[email protected]> wrote:
> Replication in version 8.0.1428 with -u NONE:
>
> :copen
> :echo getqflist({'winid':1})
>
> which returns {'winid':0}. I would expect it to return the ID of the newly
> opened window. This makes it difficult to write a function which toggles the
> qfwindow that also works when the qflist is not initialized.
>
Can you try the attached patch that fixes this issue?
>
> Any command which affects the qfwindow, including :cexpr '' makes the above
> start working as expected. Alternatively, perhaps :copen when the qflist is
> uninitialised should trigger an E776, same as :lopen when the loclist is
> uninitialised?
>
The differences is that the quickfix stack is always present but can be empty
but the location list stack is created only when a location list is added to the
stack.
Thanks,
Yegappan
--
--
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.
diff --git a/src/quickfix.c b/src/quickfix.c
index 8e745213a..ff7bf7a11 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3430,9 +3430,9 @@ qf_find_win(qf_info_T *qi)
FOR_ALL_WINDOWS(win)
if (is_qf_win(win, qi))
- break;
+ return win;
- return win;
+ return NULL;
}
/*
@@ -4944,6 +4944,27 @@ qf_id2nr(qf_info_T *qi, int_u qfid)
return -1;
}
+/*
+ * Return the quickfix/location list window identifier in the current tabpage
+ */
+ static int
+qf_winid(qf_info_T *qi)
+{
+ win_T *win;
+ int win_id = 0;
+
+ /*
+ * 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)
+ win_id = win->w_id;
+ return win_id;
+}
+
/*
* Return quickfix/location list details (title) as a
* dictionary. 'what' contains the details to return. If 'list_idx' is -1,
@@ -5053,7 +5074,7 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T
*retdict)
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);
+ 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,15 +5100,7 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T
*retdict)
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);
- }
+ status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
if ((status == OK) && (flags & QF_GETLIST_ITEMS))
{
list_T *l = list_alloc();