Karsten Hopp ad77be
To: vim-dev@vim.org
Karsten Hopp ad77be
Subject: Patch 7.2.078
Karsten Hopp ad77be
Fcc: outbox
Karsten Hopp ad77be
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ad77be
Mime-Version: 1.0
Karsten Hopp ad77be
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp ad77be
Content-Transfer-Encoding: 8bit
Karsten Hopp ad77be
------------
Karsten Hopp ad77be
Karsten Hopp ad77be
Patch 7.2.078
Karsten Hopp ad77be
Problem:    When deleting a fold that is specified with markers the cursor
Karsten Hopp ad77be
	    position may be wrong.  Folds may not be displayed properly after
Karsten Hopp ad77be
	    a delete.  Wrong fold may be deleted.
Karsten Hopp ad77be
Solution:   Fix the problems. (mostly by Lech Lorens)
Karsten Hopp ad77be
Files:	    src/fold.c
Karsten Hopp ad77be
Karsten Hopp ad77be
Karsten Hopp ad77be
*** ../vim-7.2.077/src/fold.c	Fri Nov 28 21:26:50 2008
Karsten Hopp ad77be
--- src/fold.c	Tue Jan  6 14:53:26 2009
Karsten Hopp ad77be
***************
Karsten Hopp ad77be
*** 740,746 ****
Karsten Hopp ad77be
      garray_T	*found_ga;
Karsten Hopp ad77be
      fold_T	*found_fp = NULL;
Karsten Hopp ad77be
      linenr_T	found_off = 0;
Karsten Hopp ad77be
!     int		use_level = FALSE;
Karsten Hopp ad77be
      int		maybe_small = FALSE;
Karsten Hopp ad77be
      int		level = 0;
Karsten Hopp ad77be
      linenr_T	lnum = start;
Karsten Hopp ad77be
--- 740,746 ----
Karsten Hopp ad77be
      garray_T	*found_ga;
Karsten Hopp ad77be
      fold_T	*found_fp = NULL;
Karsten Hopp ad77be
      linenr_T	found_off = 0;
Karsten Hopp ad77be
!     int		use_level;
Karsten Hopp ad77be
      int		maybe_small = FALSE;
Karsten Hopp ad77be
      int		level = 0;
Karsten Hopp ad77be
      linenr_T	lnum = start;
Karsten Hopp ad77be
***************
Karsten Hopp ad77be
*** 757,762 ****
Karsten Hopp ad77be
--- 757,763 ----
Karsten Hopp ad77be
  	gap = &curwin->w_folds;
Karsten Hopp ad77be
  	found_ga = NULL;
Karsten Hopp ad77be
  	lnum_off = 0;
Karsten Hopp ad77be
+ 	use_level = FALSE;
Karsten Hopp ad77be
  	for (;;)
Karsten Hopp ad77be
  	{
Karsten Hopp ad77be
  	    if (!foldFind(gap, lnum - lnum_off, &fp))
Karsten Hopp ad77be
***************
Karsten Hopp ad77be
*** 783,802 ****
Karsten Hopp ad77be
  	else
Karsten Hopp ad77be
  	{
Karsten Hopp ad77be
  	    lnum = found_fp->fd_top + found_fp->fd_len + found_off;
Karsten Hopp ad77be
- 	    did_one = TRUE;
Karsten Hopp ad77be
  
Karsten Hopp ad77be
  	    if (foldmethodIsManual(curwin))
Karsten Hopp ad77be
  		deleteFoldEntry(found_ga,
Karsten Hopp ad77be
  		    (int)(found_fp - (fold_T *)found_ga->ga_data), recursive);
Karsten Hopp ad77be
  	    else
Karsten Hopp ad77be
  	    {
Karsten Hopp ad77be
! 		if (found_fp->fd_top + found_off < first_lnum)
Karsten Hopp ad77be
! 		    first_lnum = found_fp->fd_top;
Karsten Hopp ad77be
! 		if (lnum > last_lnum)
Karsten Hopp ad77be
  		    last_lnum = lnum;
Karsten Hopp ad77be
! 		parseMarker(curwin);
Karsten Hopp ad77be
  		deleteFoldMarkers(found_fp, recursive, found_off);
Karsten Hopp ad77be
  	    }
Karsten Hopp ad77be
  
Karsten Hopp ad77be
  	    /* redraw window */
Karsten Hopp ad77be
  	    changed_window_setting();
Karsten Hopp ad77be
--- 784,804 ----
Karsten Hopp ad77be
  	else
Karsten Hopp ad77be
  	{
Karsten Hopp ad77be
  	    lnum = found_fp->fd_top + found_fp->fd_len + found_off;
Karsten Hopp ad77be
  
Karsten Hopp ad77be
  	    if (foldmethodIsManual(curwin))
Karsten Hopp ad77be
  		deleteFoldEntry(found_ga,
Karsten Hopp ad77be
  		    (int)(found_fp - (fold_T *)found_ga->ga_data), recursive);
Karsten Hopp ad77be
  	    else
Karsten Hopp ad77be
  	    {
Karsten Hopp ad77be
! 		if (first_lnum > found_fp->fd_top + found_off)
Karsten Hopp ad77be
! 		    first_lnum = found_fp->fd_top + found_off;
Karsten Hopp ad77be
! 		if (last_lnum < lnum)
Karsten Hopp ad77be
  		    last_lnum = lnum;
Karsten Hopp ad77be
! 		if (!did_one)
Karsten Hopp ad77be
! 		    parseMarker(curwin);
Karsten Hopp ad77be
  		deleteFoldMarkers(found_fp, recursive, found_off);
Karsten Hopp ad77be
  	    }
Karsten Hopp ad77be
+ 	    did_one = TRUE;
Karsten Hopp ad77be
  
Karsten Hopp ad77be
  	    /* redraw window */
Karsten Hopp ad77be
  	    changed_window_setting();
Karsten Hopp ad77be
***************
Karsten Hopp ad77be
*** 811,816 ****
Karsten Hopp ad77be
--- 813,822 ----
Karsten Hopp ad77be
  	    redraw_curbuf_later(INVERTED);
Karsten Hopp ad77be
  #endif
Karsten Hopp ad77be
      }
Karsten Hopp ad77be
+     else
Karsten Hopp ad77be
+ 	/* Deleting markers may make cursor column invalid. */
Karsten Hopp ad77be
+ 	check_cursor_col();
Karsten Hopp ad77be
+ 
Karsten Hopp ad77be
      if (last_lnum > 0)
Karsten Hopp ad77be
  	changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L);
Karsten Hopp ad77be
  }
Karsten Hopp ad77be
*** ../vim-7.2.077/src/version.c	Wed Dec 31 16:20:54 2008
Karsten Hopp ad77be
--- src/version.c	Tue Jan  6 15:00:36 2009
Karsten Hopp ad77be
***************
Karsten Hopp ad77be
*** 678,679 ****
Karsten Hopp ad77be
--- 678,681 ----
Karsten Hopp ad77be
  {   /* Add new patch number below this line */
Karsten Hopp ad77be
+ /**/
Karsten Hopp ad77be
+     78,
Karsten Hopp ad77be
  /**/
Karsten Hopp ad77be
Karsten Hopp ad77be
-- 
Karsten Hopp ad77be
Looking at Perl through Lisp glasses, Perl looks atrocious.
Karsten Hopp ad77be
Karsten Hopp ad77be
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ad77be
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ad77be
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp ad77be
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///