To: vim-dev@vim.org Subject: Patch 7.2.370 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.2.370 (after 7.2.356) Problem: A redraw may cause folds to be closed. Solution: Revert part of the previous patch. Add a test. (Lech Lorens) Files: src/diff.c, src/fold.c, src/option.c, src/testdir/test45.in, src/testdir/test45.ok *** ../vim-7.2.369/src/diff.c 2009-07-22 16:22:33.000000000 +0200 --- src/diff.c 2010-02-24 14:31:12.000000000 +0100 *************** *** 1117,1142 **** win_T *wp; int addbuf; /* Add buffer to diff. */ { wp->w_p_diff = TRUE; wp->w_p_scb = TRUE; wp->w_p_wrap = FALSE; # ifdef FEAT_FOLDING ! { ! win_T *old_curwin = curwin; ! ! curwin = wp; ! curbuf = curwin->w_buffer; ! set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff", OPT_LOCAL|OPT_FREE, 0); ! curwin = old_curwin; ! curbuf = curwin->w_buffer; ! wp->w_p_fdc = diff_foldcolumn; ! wp->w_p_fen = TRUE; ! wp->w_p_fdl = 0; ! foldUpdateAll(wp); ! /* make sure topline is not halfway a fold */ ! changed_window_setting_win(wp); ! } # endif #ifdef FEAT_SCROLLBIND if (vim_strchr(p_sbo, 'h') == NULL) --- 1117,1147 ---- win_T *wp; int addbuf; /* Add buffer to diff. */ { + # ifdef FEAT_FOLDING + win_T *old_curwin = curwin; + + /* close the manually opened folds */ + curwin = wp; + newFoldLevel(); + curwin = old_curwin; + # endif + wp->w_p_diff = TRUE; wp->w_p_scb = TRUE; wp->w_p_wrap = FALSE; # ifdef FEAT_FOLDING ! curwin = wp; ! curbuf = curwin->w_buffer; ! set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff", OPT_LOCAL|OPT_FREE, 0); ! curwin = old_curwin; ! curbuf = curwin->w_buffer; ! wp->w_p_fdc = diff_foldcolumn; ! wp->w_p_fen = TRUE; ! wp->w_p_fdl = 0; ! foldUpdateAll(wp); ! /* make sure topline is not halfway a fold */ ! changed_window_setting_win(wp); # endif #ifdef FEAT_SCROLLBIND if (vim_strchr(p_sbo, 'h') == NULL) *** ../vim-7.2.369/src/fold.c 2010-02-03 18:14:41.000000000 +0100 --- src/fold.c 2010-02-24 13:09:04.000000000 +0100 *************** *** 854,865 **** && fp->fd_top < bot) { fp->fd_small = MAYBE; - - /* Not sure if this is the right place to reset fd_flags (suggested by - * Lech Lorens). */ - if (wp->w_foldinvalid) - fp->fd_flags = FD_LEVEL; - ++fp; } --- 854,859 ---- *** ../vim-7.2.369/src/option.c 2010-02-11 17:02:04.000000000 +0100 --- src/option.c 2010-02-24 13:09:44.000000000 +0100 *************** *** 6586,6592 **** --- 6586,6596 ---- || *curwin->w_p_fdm == NUL) errmsg = e_invarg; else + { foldUpdateAll(curwin); + if (foldmethodIsDiff(curwin)) + newFoldLevel(); + } } # ifdef FEAT_EVAL /* 'foldexpr' */ *** ../vim-7.2.369/src/testdir/test45.in 2009-11-03 14:46:35.000000000 +0100 --- src/testdir/test45.in 2010-02-24 13:02:39.000000000 +0100 *************** *** 36,41 **** --- 36,43 ---- k:call append("$", getline(".")) jAcommentstart Acommentend:set fdl=1 3j:call append("$", getline(".")) + :set fdl=0 + zO j:call append("$", getline(".")) :" test expression folding :fun Flvl() let l = getline(v:lnum) *** ../vim-7.2.369/src/testdir/test45.ok 2009-11-03 14:46:35.000000000 +0100 --- src/testdir/test45.ok 2010-02-24 12:58:55.000000000 +0100 *************** *** 11,16 **** --- 11,17 ---- folding 9 ii 3 cc 7 gg + 8 hh expr 2 1 2 *** ../vim-7.2.369/src/version.c 2010-02-24 13:59:09.000000000 +0100 --- src/version.c 2010-02-24 14:28:20.000000000 +0100 *************** *** 683,684 **** --- 683,686 ---- { /* Add new patch number below this line */ + /**/ + 370, /**/ -- MAN: Fetchez la vache! GUARD: Quoi? MAN: Fetchez la vache! "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/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///