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

15490Fold expr problem when last line is deleted

Expand Messages
  • David Bustos
    Oct 2, 2000
      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:

      line 1
      line 2
      line 3

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

      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 @@
      if (fline.lnum == wp->w_buffer->b_ml.ml_line_count)
      + {
      + ++start; /* Remove folds after the last line. */
      + }
      fline.lvl = fline.lvl_next;

      What do you think, eh?

      David Bustos
    • Show all 2 messages in this topic