ef96630
To: vim-dev@vim.org
ef96630
Subject: Patch 7.0.117
ef96630
Fcc: outbox
ef96630
From: Bram Moolenaar <Bram@moolenaar.net>
ef96630
Mime-Version: 1.0
ef96630
Content-Type: text/plain; charset=ISO-8859-1
ef96630
Content-Transfer-Encoding: 8bit
ef96630
------------
ef96630
ef96630
Patch 7.0.117
ef96630
Problem:    Using "extend" on a syntax item inside a region with "keepend", an
ef96630
	    intermediate item may be truncated.
ef96630
	    When applying the "keepend" and there is an offset to the end
ef96630
	    pattern the highlighting of a contained item isn't adjusted.
ef96630
Solution:   Use the seen_keepend flag to remember when to apply the "keepend"
ef96630
	    flag.  Adjust the keepend highlighting properly. (Ilya Bobir)
ef96630
Files:	    src/syntax.c
ef96630
ef96630
ef96630
*** ../vim-7.0.116/src/syntax.c	Thu Apr 27 01:58:59 2006
ef96630
--- src/syntax.c	Tue Oct  3 17:00:44 2006
ef96630
***************
ef96630
*** 977,982 ****
ef96630
--- 977,983 ----
ef96630
  {
ef96630
      stateitem_T	*cur_si;
ef96630
      int		i;
ef96630
+     int		seen_keepend;
ef96630
  
ef96630
      if (startofline)
ef96630
      {
ef96630
***************
ef96630
*** 1002,1008 ****
ef96630
      /*
ef96630
       * Need to update the end of a start/skip/end that continues from the
ef96630
       * previous line.  And regions that have "keepend", because they may
ef96630
!      * influence contained items.
ef96630
       * Then check for items ending in column 0.
ef96630
       */
ef96630
      i = current_state.ga_len - 1;
ef96630
--- 1003,1012 ----
ef96630
      /*
ef96630
       * Need to update the end of a start/skip/end that continues from the
ef96630
       * previous line.  And regions that have "keepend", because they may
ef96630
!      * influence contained items.  If we've just removed "extend"
ef96630
!      * (startofline == 0) then we should update ends of normal regions
ef96630
!      * contained inside "keepend" because "extend" could have extended
ef96630
!      * these "keepend" regions as well as contained normal regions.
ef96630
       * Then check for items ending in column 0.
ef96630
       */
ef96630
      i = current_state.ga_len - 1;
ef96630
***************
ef96630
*** 1010,1019 ****
ef96630
--- 1014,1026 ----
ef96630
  	for ( ; i > keepend_level; --i)
ef96630
  	    if (CUR_STATE(i).si_flags & HL_EXTEND)
ef96630
  		break;
ef96630
+ 
ef96630
+     seen_keepend = FALSE;
ef96630
      for ( ; i < current_state.ga_len; ++i)
ef96630
      {
ef96630
  	cur_si = &CUR_STATE(i);
ef96630
  	if ((cur_si->si_flags & HL_KEEPEND)
ef96630
+ 			    || (seen_keepend && !startofline)
ef96630
  			    || (i == current_state.ga_len - 1 && startofline))
ef96630
  	{
ef96630
  	    cur_si->si_h_startpos.col = 0;	/* start highl. in col 0 */
ef96630
***************
ef96630
*** 1021,1026 ****
ef96630
--- 1028,1036 ----
ef96630
  
ef96630
  	    if (!(cur_si->si_flags & HL_MATCHCONT))
ef96630
  		update_si_end(cur_si, (int)current_col, !startofline);
ef96630
+ 
ef96630
+ 	    if (!startofline && (cur_si->si_flags & HL_KEEPEND))
ef96630
+ 		seen_keepend = TRUE;
ef96630
  	}
ef96630
      }
ef96630
      check_keepend();
ef96630
***************
ef96630
*** 2564,2569 ****
ef96630
--- 2574,2580 ----
ef96630
  {
ef96630
      int		i;
ef96630
      lpos_T	maxpos;
ef96630
+     lpos_T	maxpos_h;
ef96630
      stateitem_T	*sip;
ef96630
  
ef96630
      /*
ef96630
***************
ef96630
*** 2583,2605 ****
ef96630
  	    break;
ef96630
  
ef96630
      maxpos.lnum = 0;
ef96630
      for ( ; i < current_state.ga_len; ++i)
ef96630
      {
ef96630
  	sip = &CUR_STATE(i);
ef96630
  	if (maxpos.lnum != 0)
ef96630
  	{
ef96630
  	    limit_pos_zero(&sip->si_m_endpos, &maxpos);
ef96630
! 	    limit_pos_zero(&sip->si_h_endpos, &maxpos);
ef96630
  	    limit_pos_zero(&sip->si_eoe_pos, &maxpos);
ef96630
  	    sip->si_ends = TRUE;
ef96630
  	}
ef96630
! 	if (sip->si_ends
ef96630
! 		&& (sip->si_flags & HL_KEEPEND)
ef96630
! 		&& (maxpos.lnum == 0
ef96630
  		    || maxpos.lnum > sip->si_m_endpos.lnum
ef96630
  		    || (maxpos.lnum == sip->si_m_endpos.lnum
ef96630
! 			&& maxpos.col > sip->si_m_endpos.col)))
ef96630
! 	    maxpos = sip->si_m_endpos;
ef96630
      }
ef96630
  }
ef96630
  
ef96630
--- 2594,2623 ----
ef96630
  	    break;
ef96630
  
ef96630
      maxpos.lnum = 0;
ef96630
+     maxpos_h.lnum = 0;
ef96630
      for ( ; i < current_state.ga_len; ++i)
ef96630
      {
ef96630
  	sip = &CUR_STATE(i);
ef96630
  	if (maxpos.lnum != 0)
ef96630
  	{
ef96630
  	    limit_pos_zero(&sip->si_m_endpos, &maxpos);
ef96630
! 	    limit_pos_zero(&sip->si_h_endpos, &maxpos_h);
ef96630
  	    limit_pos_zero(&sip->si_eoe_pos, &maxpos);
ef96630
  	    sip->si_ends = TRUE;
ef96630
  	}
ef96630
! 	if (sip->si_ends && (sip->si_flags & HL_KEEPEND))
ef96630
! 	{
ef96630
! 	    if (maxpos.lnum == 0
ef96630
  		    || maxpos.lnum > sip->si_m_endpos.lnum
ef96630
  		    || (maxpos.lnum == sip->si_m_endpos.lnum
ef96630
! 			&& maxpos.col > sip->si_m_endpos.col))
ef96630
! 		maxpos = sip->si_m_endpos;
ef96630
! 	    if (maxpos_h.lnum == 0
ef96630
! 		    || maxpos_h.lnum > sip->si_h_endpos.lnum
ef96630
! 		    || (maxpos_h.lnum == sip->si_h_endpos.lnum
ef96630
! 			&& maxpos_h.col > sip->si_h_endpos.col))
ef96630
! 		maxpos_h = sip->si_h_endpos;
ef96630
! 	}
ef96630
      }
ef96630
  }
ef96630
  
ef96630
*** ../vim-7.0.116/src/version.c	Tue Oct  3 16:30:40 2006
ef96630
--- src/version.c	Tue Oct  3 16:59:50 2006
ef96630
***************
ef96630
*** 668,669 ****
ef96630
--- 668,671 ----
ef96630
  {   /* Add new patch number below this line */
ef96630
+ /**/
ef96630
+     117,
ef96630
  /**/
ef96630
ef96630
-- 
ef96630
For humans, honesty is a matter of degree.  Engineers are always honest in
ef96630
matters of technology and human relationships.  That's why it's a good idea
ef96630
to keep engineers away from customers, romantic interests, and other people
ef96630
who can't handle the truth.
ef96630
				(Scott Adams - The Dilbert principle)
ef96630
ef96630
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
ef96630
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
ef96630
\\\        download, build and distribute -- http://www.A-A-P.org        ///
ef96630
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///