Patch 8.1.0248
Problem:    duplicated quickfix code.
Solution:   Move the code to a function.
Files:      src/quickfix.c


*** ../vim-8.1.0247/src/quickfix.c      2018-08-01 17:53:04.693381270 +0200
--- src/quickfix.c      2018-08-01 20:00:00.659109066 +0200
***************
*** 4126,4131 ****
--- 4126,4145 ----
  }
  
  /*
+  * Jump to the first entry if there is one.
+  */
+     static void
+ qf_jump_first(qf_info_T *qi, int_u save_qfid, int forceit)
+ {
+     // 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".
   */
      int
***************
*** 4247,4258 ****
        apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
                                               curbuf->b_fname, TRUE, 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 */
!     }
  
  cleanup:
      mch_remove(fname);
--- 4261,4268 ----
        apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
                                               curbuf->b_fname, TRUE, curbuf);
      if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid))
!       // display the first error
!       qf_jump_first(qi, save_qfid, FALSE);
  
  cleanup:
      mch_remove(fname);
***************
*** 4650,4659 ****
      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 */
      }
  }
  
--- 4660,4667 ----
      if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)
            && qflist_valid(wp, save_qfid))
      {
!       // display the first error
!       qf_jump_first(qi, save_qfid, eap->forceit);
      }
  }
  
***************
*** 6361,6370 ****
                                                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 */
            }
        }
      }
--- 6369,6376 ----
                                                eap->cmdidx == CMD_lbuffer)
                    && qflist_valid(wp, save_qfid))
            {
!               // display the first error
!               qf_jump_first(qi, save_qfid, eap->forceit);
            }
        }
      }
***************
*** 6443,6452 ****
                                                   || 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);
            }
        }
        else
--- 6449,6456 ----
                                                   || eap->cmdidx == CMD_lexpr)
                    && qflist_valid(wp, save_qfid))
            {
!               // display the first error
!               qf_jump_first(qi, save_qfid, eap->forceit);
            }
        }
        else
*** ../vim-8.1.0247/src/version.c       2018-08-07 19:45:22.623218411 +0200
--- src/version.c       2018-08-07 19:47:15.006608513 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     248,
  /**/

-- 
TALL KNIGHT: We are now no longer the Knights Who Say Ni!
ONE KNIGHT:  Ni!
OTHERS:      Sh!
ONE KNIGHT:  (whispers) Sorry.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui