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

15498Re: Fold expr problem when last line is deleted

Expand Messages
  • Bram Moolenaar
    Oct 2, 2000
    • 0 Attachment
      David Bustos wrote:

      > 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.

      Yes, something goes wrong here.

      > 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:

      Hmm, I would say the computation of the level is already wrong. It returns
      "0" for the last line, which it should be "-1". After correcting that it no
      longer runs into the problem of deleting the fold for the last line.
      However, the fold includes lines that don't exist...

      There is another error in calling the fold update function with the wrong
      arguments. I'll look into that...

      OK, it seems to work well now. You'll see it in the next release...

      In a world without fences, who needs Gates and Windows?

      /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
      \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
    • Show all 2 messages in this topic