Hi Ein! On Fr, 24 Mai 2013, Ein Brown wrote:
> Hi, I have encountered a bug where my folds become 'corrupted' and > unrecognized by vim. I looks like this is caused by using :move on a closed > fold under the right circumstances. > > The SO question has more details: > http://stackoverflow.com/questions/16592654/in-vim-why-is-move-randomly-corrupting-my-folds > > at the bottom of the SO question (under 'edit') I explain ways to run into > the bug without the Alt-Up / Alt-Down mapping. I just saw the problem yesterday. Here is an simpler example of the bug: #v+ chrisbra@R500 % cat foldmarker_bug.txt vim: fdm=marker fold A {{{ some text here }}} fold B {{{ some text here }}} fold C {{{ some text here }}} fold D {{{ some text here }}} chrisbra@R500 vim -u NONE -N foldmarker_bug.txt :10 :4m #v- Note, that the fold B stays open and it is not possible to close it. Debugging it with gdb, you'll find, that wp->w_folds get invalid (e.g. is out of order). I think this patch fixes it. iff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -784,6 +784,7 @@ */ last_line = curbuf->b_ml.ml_line_count; mark_adjust(line1, line2, last_line - line2, 0L); + changed_lines(last_line - num_lines + 1, 0, last_line + 1, num_lines); if (dest >= line2) { mark_adjust(line2 + 1, dest, -num_lines, 0L); @@ -800,6 +801,7 @@ mark_adjust(last_line - num_lines + 1, last_line, -(last_line - dest - extra), 0L); + changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra); /* * Now we delete the original text -- webb */ BTW: I think, there is also an error in fold.c: diff --git a/src/fold.c b/src/fold.c --- a/src/fold.c +++ b/src/fold.c @@ -849,8 +849,8 @@ fold_T *fp; /* Mark all folds from top to bot as maybe-small. */ - (void)foldFind(&curwin->w_folds, top, &fp); - while (fp < (fold_T *)curwin->w_folds.ga_data + curwin->w_folds.ga_len + (void)foldFind(&wp->w_folds, top, &fp); + while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len && fp->fd_top < bot) { fp->fd_small = MAYBE; regards, Christian -- -- -- 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/groups/opt_out.
