diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-13 00:38:42 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-13 00:47:30 -0400 |
commit | fba9c724957f0a18cb42ffdb75375241da08c6c6 (patch) | |
tree | 97154123002e9148bf260ad0ef92b8b41aa5d1ae /src/nvim/quickfix.c | |
parent | 4ef9ad0514bde2694ca51b0d48f86ffbb6384f56 (diff) | |
download | rneovim-fba9c724957f0a18cb42ffdb75375241da08c6c6.tar.gz rneovim-fba9c724957f0a18cb42ffdb75375241da08c6c6.tar.bz2 rneovim-fba9c724957f0a18cb42ffdb75375241da08c6c6.zip |
vim-patch:8.1.0259: no test for fixed quickfix issue
Problem: No test for fixed quickfix issue.
Solution: Add a test. Clean up the code a bit. (Yegappan Lakshmanan)
https://github.com/vim/vim/commit/3f347e4716c44cf6458be407e712e3d708d82580
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index d9f09dbb55..6e14888ca8 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -728,6 +728,15 @@ static int qf_get_nextline(qfstate_T *state) return QF_OK; } +// Returns true if the specified quickfix/location list is empty. +static bool qf_list_empty(const qf_info_T *qi, int qf_idx) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT +{ + if (qi == NULL || qf_idx < 0 || qf_idx >= LISTCOUNT) { + return true; + } + return qi->qf_lists[qf_idx].qf_count <= 0; +} /// Parse a line and get the quickfix fields. /// Return the QF_ status. @@ -2906,8 +2915,7 @@ void qf_view_result(bool split) if (IS_LL_WINDOW(curwin)) { qi = GET_LOC_LIST(curwin); } - if (qi == NULL - || qi->qf_lists[qi->qf_curlist].qf_count == 0) { + if (qf_list_empty(qi, qi->qf_curlist)) { EMSG(_(e_quickfix)); return; } @@ -3456,7 +3464,8 @@ static void qf_jump_first(qf_info_T *qi, unsigned save_qfid, int forceit) if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { qi->qf_curlist = qf_id2nr(qi, save_qfid); } - if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { + // Autocommands might have cleared the list, check for it + if (!qf_list_empty(qi, qi->qf_curlist)) { qf_jump(qi, 0, 0, forceit); } } |