diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-13 00:20:23 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-13 00:35:14 -0400 |
commit | 4ef9ad0514bde2694ca51b0d48f86ffbb6384f56 (patch) | |
tree | 730a8d8481cae1898c6f64f52366c64d5092978d /src | |
parent | 8ba492e4e2bff7104cdd1c3bcca8831e094ad193 (diff) | |
download | rneovim-4ef9ad0514bde2694ca51b0d48f86ffbb6384f56.tar.gz rneovim-4ef9ad0514bde2694ca51b0d48f86ffbb6384f56.tar.bz2 rneovim-4ef9ad0514bde2694ca51b0d48f86ffbb6384f56.zip |
vim-patch:8.1.0248: duplicated quickfix code
Problem: duplicated quickfix code.
Solution: Move the code to a function.
https://github.com/vim/vim/commit/8d8a65e389cef318ae661ff0fe7b1b00fd7cb25f
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/quickfix.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 8d76863d90..d9f09dbb55 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3448,6 +3448,19 @@ static int qf_id2nr(const qf_info_T *const qi, const unsigned qfid) return INVALID_QFIDX; } +// Jump to the first entry if there is one. +static void qf_jump_first(qf_info_T *qi, unsigned save_qfid, int forceit) + FUNC_ATTR_NONNULL_ALL +{ + // If autocommands changed the current list, then restore it + 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) { + qf_jump(qi, 0, 0, forceit); + } +} + /* * Return TRUE when using ":vimgrep" for ":grep". */ @@ -3549,11 +3562,8 @@ void ex_make(exarg_T *eap) curbuf); } if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid)) { - // If autocommands changed the current list, then restore it. - if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { - qi->qf_curlist = qf_id2nr(qi, save_qfid); - } - qf_jump(qi, 0, 0, false); // display first error + // display the first error + qf_jump_first(qi, save_qfid, false); } cleanup: @@ -3919,11 +3929,8 @@ void ex_cfile(exarg_T *eap) // list. if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile) && qflist_valid(wp, save_qfid)) { - // If autocommands changed the current list, then restore it - if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { - qi->qf_curlist = qf_id2nr(qi, save_qfid); - } - qf_jump(qi, 0, 0, eap->forceit); // display first error + // display the first error + qf_jump_first(qi, save_qfid, eap->forceit); } } @@ -5421,11 +5428,8 @@ void ex_cbuffer(exarg_T *eap) // free the list. if (res > 0 && (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer) && qflist_valid(wp, save_qfid)) { - // If autocommands changed the current list, then restore it. - if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { - qi->qf_curlist = qf_id2nr(qi, save_qfid); - } - qf_jump(qi, 0, 0, eap->forceit); // display first error + // display the first error + qf_jump_first(qi, save_qfid, eap->forceit); } } } @@ -5503,11 +5507,8 @@ void ex_cexpr(exarg_T *eap) if (res > 0 && (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr) && qflist_valid(wp, save_qfid)) { - // If autocommands changed the current list, then restore it. - if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { - qi->qf_curlist = qf_id2nr(qi, save_qfid); - } - qf_jump(qi, 0, 0, eap->forceit); + // display the first error + qf_jump_first(qi, save_qfid, eap->forceit); } } else { EMSG(_("E777: String or List expected")); |