To: vim-dev@vim.org Subject: Patch 6.2.208 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.208 Problem: When using fold markers, three lines in a row have the start marker and deleting the first one with "dd", a nested fold is not deleted. (Kamil Burzynski) Using marker folding, a level 1 fold doesn't stop when it is followed by "{{{2", starting a level 2 fold. Solution: Don't stop updating folds at the end of a change when the nesting level of folds is larger than the fold level. Correctly compute the number of folds that start at "{{{2". Also avoid a crash for a NULL pointer. Files: src/fold.c *** ../vim-6.2.207/src/fold.c Mon Dec 29 20:30:12 2003 --- src/fold.c Sat Jan 24 17:01:17 2004 *************** *** 2262,2270 **** && getlevel != foldlevelExpr && getlevel != foldlevelSyntax) break; ! if (lvl == level ! && foldFind(&fp->fd_nested, flp->lnum - fp->fd_top, &fp2)) ! bot = fp2->fd_top + fp2->fd_len - 1 + fp->fd_top; else if (fp->fd_top + fp->fd_len <= flp->lnum && lvl >= level) finish = TRUE; else --- 2262,2287 ---- && getlevel != foldlevelExpr && getlevel != foldlevelSyntax) break; ! i = 0; ! fp2 = fp; ! if (lvl >= level) ! { ! /* Compute how deep the folds currently are, if it's deeper ! * than "lvl" then some must be deleted, need to update ! * at least one nested fold. */ ! ll = flp->lnum - fp->fd_top; ! while (foldFind(&fp2->fd_nested, ll, &fp2)) ! { ! ++i; ! ll -= fp2->fd_top; ! } ! } ! if (lvl < level + i) ! { ! foldFind(&fp->fd_nested, flp->lnum - fp->fd_top, &fp2); ! if (fp2 != NULL) ! bot = fp2->fd_top + fp2->fd_len - 1 + fp->fd_top; ! } else if (fp->fd_top + fp->fd_len <= flp->lnum && lvl >= level) finish = TRUE; else *************** *** 2959,2964 **** --- 2976,2982 ---- char_u *startmarker; int cstart; int cend; + int start_lvl = flp->lvl; char_u *s; int n; *************** *** 2987,2993 **** { flp->lvl = n; flp->lvl_next = n; ! ++flp->start; } } else --- 3005,3014 ---- { flp->lvl = n; flp->lvl_next = n; ! if (n < start_lvl) ! flp->start = 0; ! else ! flp->start = n - start_lvl; } } else *************** *** 3036,3042 **** fline_T *flp; { #ifndef FEAT_SYN_HL ! flp->start = FALSE; flp->lvl = 0; #else linenr_T lnum = flp->lnum + flp->off; --- 3057,3063 ---- fline_T *flp; { #ifndef FEAT_SYN_HL ! flp->start = 0; flp->lvl = 0; #else linenr_T lnum = flp->lnum + flp->off; *************** *** 3044,3050 **** /* Use the maximum fold level at the start of this line and the next. */ flp->lvl = syn_get_foldlevel(flp->wp, lnum); ! flp->start = FALSE; if (lnum < flp->wp->w_buffer->b_ml.ml_line_count) { n = syn_get_foldlevel(flp->wp, lnum + 1); --- 3065,3071 ---- /* Use the maximum fold level at the start of this line and the next. */ flp->lvl = syn_get_foldlevel(flp->wp, lnum); ! flp->start = 0; if (lnum < flp->wp->w_buffer->b_ml.ml_line_count) { n = syn_get_foldlevel(flp->wp, lnum + 1); *** ../vim-6.2.207/src/version.c Sun Jan 25 20:30:03 2004 --- src/version.c Sun Jan 25 20:32:00 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 208, /**/ -- JOHN CLEESE PLAYED: SECOND SOLDIER WITH A KEEN INTEREST IN BIRDS, LARGE MAN WITH DEAD BODY, BLACK KNIGHT, MR NEWT (A VILLAGE BLACKSMITH INTERESTED IN BURNING WITCHES), A QUITE EXTRAORDINARILY RUDE FRENCHMAN, TIM THE WIZARD, SIR LAUNCELOT "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///