Loading ...
Sorry, an error occurred while loading the content.

Patch 6.2.072

Expand Messages
  • Bram Moolenaar
    Patch 6.2.072 Problem: When using expression folding, foldexpr() mostly returns -1 for the previous line, which makes it difficult to write a fold
    Message 1 of 1 , Sep 2, 2003
    • 0 Attachment
      Patch 6.2.072
      Problem: When using expression folding, foldexpr() mostly returns -1 for
      the previous line, which makes it difficult to write a fold
      expression.
      Solution: Make the level of the previous line available while still looking
      for the end of a fold.
      Files: src/fold.c


      *** ../vim-6.2.071/src/fold.c Fri Apr 18 14:49:33 2003
      --- src/fold.c Wed Aug 13 21:28:57 2003
      ***************
      *** 72,77 ****
      --- 72,87 ----
      static linenr_T invalid_top = (linenr_T)0;
      static linenr_T invalid_bot = (linenr_T)0;

      + /*
      + * When using 'foldexpr' we sometimes get the level of the next line, which
      + * calls foldlevel() to get the level of the current line, which hasn't been
      + * stored yet. To get around this chicken-egg problem the level of the
      + * previous line is stored here when available. prev_lnum is zero when the
      + * level is not available.
      + */
      + static linenr_T prev_lnum = 0;
      + static int prev_lnum_lvl = -1;
      +
      /* Flags used for "done" argument of setManualFold. */
      #define DONE_NOTHING 0
      #define DONE_ACTION 1 /* did close or open a fold */
      ***************
      *** 247,252 ****
      --- 257,264 ----
      * an undefined fold level. Otherwise update the folds first. */
      if (invalid_top == (linenr_T)0)
      checkupdate(curwin);
      + else if (lnum == prev_lnum && prev_lnum_lvl >= 0)
      + return prev_lnum_lvl;
      else if (lnum >= invalid_top && lnum <= invalid_bot)
      return -1;

      ***************
      *** 2450,2455 ****
      --- 2462,2471 ----
      ll = flp->lnum + 1;
      while (!got_int)
      {
      + /* Make the previous level available to foldlevel(). */
      + prev_lnum = flp->lnum;
      + prev_lnum_lvl = flp->lvl;
      +
      if (++flp->lnum > linecount)
      break;
      flp->lvl = flp->lvl_next;
      ***************
      *** 2457,2462 ****
      --- 2473,2479 ----
      if (flp->lvl >= 0 || flp->had_end <= MAX_LEVEL)
      break;
      }
      + prev_lnum = 0;
      if (flp->lnum > linecount)
      break;

      *** ../vim-6.2.071/src/version.c Tue Aug 12 20:01:59 2003
      --- src/version.c Tue Sep 2 22:21:15 2003
      ***************
      *** 632,633 ****
      --- 632,635 ----
      { /* Add new patch number below this line */
      + /**/
      + 72,
      /**/

      --
      I'd like to meet the man who invented sex and see what he's working on now.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.