diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/main.c | 4 | ||||
-rw-r--r-- | src/nvim/option.c | 2 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 38 |
3 files changed, 24 insertions, 20 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index 06c1124976..bc960f239a 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -239,8 +239,8 @@ void early_init(mparm_T *paramp) set_lang_var(); // set v:lang and v:ctype - // initialize global quickfix list - qf_init_quickfix_stack(); + // initialize quickfix list + qf_init_stack(); } #ifdef MAKE_LIB diff --git a/src/nvim/option.c b/src/nvim/option.c index 5b29fcc5e3..4bc05ccea3 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2714,7 +2714,7 @@ static const char *did_set_xhistory(optset_T *args) OptInt *arg = is_p_chi ? &p_chi : (OptInt *)args->os_varp; if (is_p_chi) { - qf_resize_quickfix_stack((int)(*arg)); + qf_resize_stack((int)(*arg)); } else { ll_resize_stack(win, (int)(*arg)); } diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index cde12c9d8f..0e6b7b9ce4 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2001,11 +2001,11 @@ static int qf_add_entry(qf_list_T *qfl, char *dir, char *fname, char *module, in return QF_OK; } -/// Resize global quickfix stack to be able to hold n amount of lists. -void qf_resize_quickfix_stack(int n) +/// Resize quickfix stack to be able to hold n amount of lists. +void qf_resize_stack(int n) { assert(ql_info != NULL); - qf_resize_stack(ql_info, n); + qf_resize_stack_base(ql_info, n); } /// Resize location list stack for window 'wp' to be able to hold n amount of lists. @@ -2020,11 +2020,12 @@ void ll_resize_stack(win_T *wp, int n) } qf_info_T *qi = ll_get_or_alloc_list(wp); - qf_resize_stack(qi, n); + qf_resize_stack_base(qi, n); } -/// Resize quickfix stack to be able to hold n amount of quickfix lists. -static void qf_resize_stack(qf_info_T *qi, int n) +/// Resize quickfix/location lists stack to be able to hold n amount of lists. +static void qf_resize_stack_base(qf_info_T *qi, int n) + FUNC_ATTR_NONNULL_ALL { int amount_to_rm = 0; size_t lsz = sizeof(*qi->qf_lists); @@ -2054,13 +2055,10 @@ static void qf_resize_stack(qf_info_T *qi, int n) qf_update_buffer(qi, NULL); } -/// Initialize global quickfix list, should only be called once. -void qf_init_quickfix_stack(void) +/// Initialize quickfix list, should only be called once. +void qf_init_stack(void) { - ql_info_actual.qf_lists = qf_alloc_list_stack((int)p_chi); - ql_info = &ql_info_actual; - ql_info->qfl_type = QFLT_QUICKFIX; - ql_info->qf_maxcount = (int)p_chi; + ql_info = qf_alloc_stack(QFLT_QUICKFIX, (int)p_chi); } /// Sync a location list window's 'lhistory' value to the parent window @@ -2093,8 +2091,13 @@ static void qf_sync_win_to_llw(win_T *pwp) static qf_info_T *qf_alloc_stack(qfltype_T qfltype, int n) FUNC_ATTR_NONNULL_RET { - qf_info_T *qi = xcalloc(1, sizeof(qf_info_T)); - qi->qf_refcount++; + qf_info_T *qi; + if (qfltype == QFLT_QUICKFIX) { + qi = &ql_info_actual; + } else { + qi = xcalloc(1, sizeof(qf_info_T)); + qi->qf_refcount++; + } qi->qfl_type = qfltype; qi->qf_bufnr = INVALID_QFBUFNR; qi->qf_lists = qf_alloc_list_stack(n); @@ -7049,12 +7052,13 @@ static void qf_free_stack(win_T *wp, qf_info_T *qi) /// When "what" is not NULL then only set some properties. int set_errorlist(win_T *wp, list_T *list, int action, char *title, dict_T *what) { - qf_info_T *qi = ql_info; - assert(qi != NULL); - + qf_info_T *qi; if (wp != NULL) { qi = ll_get_or_alloc_list(wp); + } else { + qi = ql_info; } + assert(qi != NULL); if (action == 'f') { // Free the entire quickfix or location list stack |