diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-04-08 12:06:58 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2025-04-08 13:06:20 +0800 |
commit | 454abde1aa99fde0e50b65a973f0d2eaabd4dc1e (patch) | |
tree | 9fd7761719eb24df79f20febb824adf1185d69be /src/nvim/quickfix.c | |
parent | 00eff4b196521adc35d11c605decacef5bc98fa3 (diff) | |
download | rneovim-454abde1aa99fde0e50b65a973f0d2eaabd4dc1e.tar.gz rneovim-454abde1aa99fde0e50b65a973f0d2eaabd4dc1e.tar.bz2 rneovim-454abde1aa99fde0e50b65a973f0d2eaabd4dc1e.zip |
vim-patch:9.1.1287: quickfix code can be further improved
Problem: quickfix code can be further improved (after v9.1.1283)
Solution: slightly refactor quickfix.c (Hirohito Higashi)
- remove error message output
- adjust comments
- rename functions:
- qf_init_quickfix_stack() --> qf_init_stack()
- qf_resize_quickfix_stack() --> qf_resize_stack()
- qf_resize_stack() --> qf_resize_stack_base()
Now qf_alloc_stack() can handle both quickfix/location lists.
closes: vim/vim#17068
https://github.com/vim/vim/commit/adcfb6caeb1c9c54448fff8d5812c3dca2ba0d03
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 38 |
1 files changed, 21 insertions, 17 deletions
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 |