Hi Yutao!

On Di, 14 Apr 2015, Yutao Yuan wrote:

> Steps to reproduce:
> 
> 1. create a buffer with two lines.
> 2. set 'fdm' to indent.
> 3. insert two lines with some text indented according to 'sw' to create a 
> fold.
> 4. execute :m1 on the first line.
> 5. close the fold and try to delete the fold.
> 
> This will cause a E315 error. Reproducible with latest version 7.4.698
> with command line flag -u NONE -N.

I see two problems here.
1) First after step 4 (:m1) the fold info is destroyed and I am not able
   to fold the lines again. This looks like the problem I have been 
   trying to fix with this patch:
   https://groups.google.com/d/msg/vim_dev/5SD5E_hyGPk/-ojYGyeNbwYJ

2) After step 5 (trying to delete all the lines within a fold, I first
   thought you were trying to delete the fold, which doesn't work for 
   indented folded lines), I get a bunch of E315 errors.
   The problem here is that hasFoldingWin() function sets lnume to the 
   line after the fold, which is actually invalid, because the buffer 
   does not have that many lines. This also causes that foldtext() 
   returns an empty string for that region. So in the following patch, I 
   check, that the last line is actually a valid buffer line and if it 
   is larger than the lines of the buffer, set it to the end of the 
   buffer (see attached patch).

Both patch are also available here:
https://github.com/chrisbra/vim-mq-patches/blob/master/fold_bug
https://github.com/chrisbra/vim-mq-patches/blob/master/move_folding_bug

Best,
Christian
-- 
Es ist mir sehr wahrscheinlich daß die meisten Irrtümer des Pöbels
aus der Sprache stammen.
                -- Georg Christoph Lichtenberg

-- 
-- 
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.
diff --git a/src/fold.c b/src/fold.c
--- a/src/fold.c
+++ b/src/fold.c
@@ -234,6 +234,8 @@ hasFoldingWin(win, lnum, firstp, lastp, 
 	return FALSE;
     }
 
+    if (last > win->w_buffer->b_ml.ml_line_count)
+	last = win->w_buffer->b_ml.ml_line_count;
     if (lastp != NULL)
 	*lastp = last;
     if (firstp != NULL)

Raspunde prin e-mail lui