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

15490Fold expr problem when last line is deleted

Expand Messages
  • David Bustos
    Oct 2, 2000
    • 0 Attachment
      I noticed that when I have my fold method set to an expression and I
      delete the last or next to last line in a buffer, vim thinks that the
      new last line is no longer in a fold, when it should be. For example:

      Type:
      line 1
      line 2
      line 3

      Set:
      :set foldexpr=(v:lnum==1)?1:'=' " One fold from the top to the bottom
      :set foldmethod=expr

      Issue:
      G dd zc

      vim will inform you that there is no fold there, where clearly there
      should be.

      After snooping around a bit, I found a fix for fold.c. However, I'm
      having difficulty following the code there and am not sure if this is
      the best solution. Here it goes:


      --- - Mon Oct 2 03:16:56 2000
      +++ vim60h/src/fold.c Mon Oct 2 02:53:58 2000
      @@ -1299,7 +1299,10 @@
      else
      {
      if (fline.lnum == wp->w_buffer->b_ml.ml_line_count)
      + {
      + ++start; /* Remove folds after the last line. */
      break;
      + }
      ++fline.lnum;
      fline.lvl = fline.lvl_next;
      getlevel(&fline);


      What do you think, eh?

      David Bustos
    • Show all 2 messages in this topic