comparison src/quickfix.c @ 13115:9812a9ca3ab2 v8.0.1432

patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window commit https://github.com/vim/vim/commit/2ec364e94dbc080ccdf6c5dfc6f1653b5b7ded64 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 27 11:52:13 2018 +0100 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, closes #2541)
author Christian Brabandt <cb@256bit.org>
date Sat, 27 Jan 2018 12:00:06 +0100
parents bfa7f5b23c53
children ac42c4b11dbc
comparison
equal deleted inserted replaced
13114:d9d636740510 13115:9812a9ca3ab2
3419 return FALSE; 3419 return FALSE;
3420 } 3420 }
3421 3421
3422 /* 3422 /*
3423 * Find a window displaying the quickfix/location list 'qi' 3423 * Find a window displaying the quickfix/location list 'qi'
3424 * Searches in only the windows opened in the current tab. 3424 * Only searches in the current tabpage.
3425 */ 3425 */
3426 static win_T * 3426 static win_T *
3427 qf_find_win(qf_info_T *qi) 3427 qf_find_win(qf_info_T *qi)
3428 { 3428 {
3429 win_T *win; 3429 win_T *win;
3430 3430
3431 FOR_ALL_WINDOWS(win) 3431 FOR_ALL_WINDOWS(win)
3432 if (is_qf_win(win, qi)) 3432 if (is_qf_win(win, qi))
3433 break; 3433 return win;
3434 3434 return NULL;
3435 return win;
3436 } 3435 }
3437 3436
3438 /* 3437 /*
3439 * Find a quickfix buffer. 3438 * Find a quickfix buffer.
3440 * Searches in windows opened in all the tabs. 3439 * Searches in windows opened in all the tabs.
4943 return qf_idx; 4942 return qf_idx;
4944 return -1; 4943 return -1;
4945 } 4944 }
4946 4945
4947 /* 4946 /*
4947 * Return the quickfix/location list window identifier in the current tabpage.
4948 */
4949 static int
4950 qf_winid(qf_info_T *qi)
4951 {
4952 win_T *win;
4953
4954 /* The quickfix window can be opened even if the quickfix list is not set
4955 * using ":copen". This is not true for location lists. */
4956 if (qi == NULL)
4957 return 0;
4958 win = qf_find_win(qi);
4959 if (win != NULL)
4960 return win->w_id;
4961 return 0;
4962 }
4963
4964 /*
4948 * Return quickfix/location list details (title) as a 4965 * Return quickfix/location list details (title) as a
4949 * dictionary. 'what' contains the details to return. If 'list_idx' is -1, 4966 * dictionary. 'what' contains the details to return. If 'list_idx' is -1,
4950 * then current list is used. Otherwise the specified list is used. 4967 * then current list is used. Otherwise the specified list is used.
4951 */ 4968 */
4952 int 4969 int
5051 status = FAIL; 5068 status = FAIL;
5052 } 5069 }
5053 if ((status == OK) && (flags & QF_GETLIST_NR)) 5070 if ((status == OK) && (flags & QF_GETLIST_NR))
5054 status = dict_add_nr_str(retdict, "nr", 0L, NULL); 5071 status = dict_add_nr_str(retdict, "nr", 0L, NULL);
5055 if ((status == OK) && (flags & QF_GETLIST_WINID)) 5072 if ((status == OK) && (flags & QF_GETLIST_WINID))
5056 status = dict_add_nr_str(retdict, "winid", 0L, NULL); 5073 status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
5057 if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) 5074 if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
5058 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)""); 5075 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
5059 if ((status == OK) && (flags & QF_GETLIST_ID)) 5076 if ((status == OK) && (flags & QF_GETLIST_ID))
5060 status = dict_add_nr_str(retdict, "id", 0L, NULL); 5077 status = dict_add_nr_str(retdict, "id", 0L, NULL);
5061 if ((status == OK) && (flags & QF_GETLIST_IDX)) 5078 if ((status == OK) && (flags & QF_GETLIST_IDX))
5077 status = dict_add_nr_str(retdict, "title", 0L, t); 5094 status = dict_add_nr_str(retdict, "title", 0L, t);
5078 } 5095 }
5079 if ((status == OK) && (flags & QF_GETLIST_NR)) 5096 if ((status == OK) && (flags & QF_GETLIST_NR))
5080 status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL); 5097 status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL);
5081 if ((status == OK) && (flags & QF_GETLIST_WINID)) 5098 if ((status == OK) && (flags & QF_GETLIST_WINID))
5082 { 5099 status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
5083 win_T *win;
5084 int win_id = 0;
5085
5086 win = qf_find_win(qi);
5087 if (win != NULL)
5088 win_id = win->w_id;
5089 status = dict_add_nr_str(retdict, "winid", win_id, NULL);
5090 }
5091 if ((status == OK) && (flags & QF_GETLIST_ITEMS)) 5100 if ((status == OK) && (flags & QF_GETLIST_ITEMS))
5092 { 5101 {
5093 list_T *l = list_alloc(); 5102 list_T *l = list_alloc();
5094 if (l != NULL) 5103 if (l != NULL)
5095 { 5104 {