410e2f9
To: vim-dev@vim.org
410e2f9
Subject: Patch 7.1.227
410e2f9
Fcc: outbox
410e2f9
From: Bram Moolenaar <Bram@moolenaar.net>
410e2f9
Mime-Version: 1.0
410e2f9
Content-Type: text/plain; charset=ISO-8859-1
410e2f9
Content-Transfer-Encoding: 8bit
410e2f9
------------
410e2f9
410e2f9
Patch 7.1.227
410e2f9
Problem:    Hang in syntax HL when moving over a ")". (Dominique Pelle)
410e2f9
Solution:   Avoid storing a syntax state in the wrong position in the list of
410e2f9
	    remembered states.
410e2f9
Files:	    src/syntax.c
410e2f9
410e2f9
410e2f9
*** ../vim-7.1.226/src/syntax.c	Sat Jan 12 16:45:25 2008
410e2f9
--- src/syntax.c	Sat Jan 12 16:45:44 2008
410e2f9
***************
410e2f9
*** 372,378 ****
410e2f9
  static int syn_stack_cleanup __ARGS((void));
410e2f9
  static void syn_stack_free_entry __ARGS((buf_T *buf, synstate_T *p));
410e2f9
  static synstate_T *syn_stack_find_entry __ARGS((linenr_T lnum));
410e2f9
! static synstate_T *store_current_state __ARGS((synstate_T *sp));
410e2f9
  static void load_current_state __ARGS((synstate_T *from));
410e2f9
  static void invalidate_current_state __ARGS((void));
410e2f9
  static int syn_stack_equal __ARGS((synstate_T *sp));
410e2f9
--- 372,378 ----
410e2f9
  static int syn_stack_cleanup __ARGS((void));
410e2f9
  static void syn_stack_free_entry __ARGS((buf_T *buf, synstate_T *p));
410e2f9
  static synstate_T *syn_stack_find_entry __ARGS((linenr_T lnum));
410e2f9
! static synstate_T *store_current_state __ARGS((void));
410e2f9
  static void load_current_state __ARGS((synstate_T *from));
410e2f9
  static void invalidate_current_state __ARGS((void));
410e2f9
  static int syn_stack_equal __ARGS((synstate_T *sp));
410e2f9
***************
410e2f9
*** 464,470 ****
410e2f9
      synstate_T	*p;
410e2f9
      synstate_T	*last_valid = NULL;
410e2f9
      synstate_T	*last_min_valid = NULL;
410e2f9
!     synstate_T	*sp, *prev;
410e2f9
      linenr_T	parsed_lnum;
410e2f9
      linenr_T	first_stored;
410e2f9
      int		dist;
410e2f9
--- 464,470 ----
410e2f9
      synstate_T	*p;
410e2f9
      synstate_T	*last_valid = NULL;
410e2f9
      synstate_T	*last_min_valid = NULL;
410e2f9
!     synstate_T	*sp, *prev = NULL;
410e2f9
      linenr_T	parsed_lnum;
410e2f9
      linenr_T	first_stored;
410e2f9
      int		dist;
410e2f9
***************
410e2f9
*** 502,508 ****
410e2f9
  	if (!current_state_stored)
410e2f9
  	{
410e2f9
  	    ++current_lnum;
410e2f9
! 	    (void)store_current_state(NULL);
410e2f9
  	}
410e2f9
  
410e2f9
  	/*
410e2f9
--- 502,508 ----
410e2f9
  	if (!current_state_stored)
410e2f9
  	{
410e2f9
  	    ++current_lnum;
410e2f9
! 	    (void)store_current_state();
410e2f9
  	}
410e2f9
  
410e2f9
  	/*
410e2f9
***************
410e2f9
*** 558,564 ****
410e2f9
  	dist = 999999;
410e2f9
      else
410e2f9
  	dist = syn_buf->b_ml.ml_line_count / (syn_buf->b_sst_len - Rows) + 1;
410e2f9
-     prev = syn_stack_find_entry(current_lnum);
410e2f9
      while (current_lnum < lnum)
410e2f9
      {
410e2f9
  	syn_start_line();
410e2f9
--- 558,563 ----
410e2f9
***************
410e2f9
*** 573,581 ****
410e2f9
  	     * equal to the current state.  If so, then validate all saved
410e2f9
  	     * states that depended on a change before the parsed line. */
410e2f9
  	    if (prev == NULL)
410e2f9
  		sp = syn_buf->b_sst_first;
410e2f9
  	    else
410e2f9
! 		sp = prev->sst_next;
410e2f9
  	    if (sp != NULL
410e2f9
  		    && sp->sst_lnum == current_lnum
410e2f9
  		    && syn_stack_equal(sp))
410e2f9
--- 572,584 ----
410e2f9
  	     * equal to the current state.  If so, then validate all saved
410e2f9
  	     * states that depended on a change before the parsed line. */
410e2f9
  	    if (prev == NULL)
410e2f9
+ 		prev = syn_stack_find_entry(current_lnum - 1);
410e2f9
+ 	    if (prev == NULL)
410e2f9
  		sp = syn_buf->b_sst_first;
410e2f9
  	    else
410e2f9
! 		sp = prev;
410e2f9
! 	    while (sp != NULL && sp->sst_lnum < current_lnum)
410e2f9
! 		sp = sp->sst_next;
410e2f9
  	    if (sp != NULL
410e2f9
  		    && sp->sst_lnum == current_lnum
410e2f9
  		    && syn_stack_equal(sp))
410e2f9
***************
410e2f9
*** 601,607 ****
410e2f9
  	    else if (prev == NULL
410e2f9
  			|| current_lnum == lnum
410e2f9
  			|| current_lnum >= prev->sst_lnum + dist)
410e2f9
! 		prev = store_current_state(prev);
410e2f9
  	}
410e2f9
  
410e2f9
  	/* This can take a long time: break when CTRL-C pressed.  The current
410e2f9
--- 604,610 ----
410e2f9
  	    else if (prev == NULL
410e2f9
  			|| current_lnum == lnum
410e2f9
  			|| current_lnum >= prev->sst_lnum + dist)
410e2f9
! 		prev = store_current_state();
410e2f9
  	}
410e2f9
  
410e2f9
  	/* This can take a long time: break when CTRL-C pressed.  The current
410e2f9
***************
410e2f9
*** 1353,1369 ****
410e2f9
   * The current state must be valid for the start of the current_lnum line!
410e2f9
   */
410e2f9
      static synstate_T *
410e2f9
! store_current_state(sp)
410e2f9
!     synstate_T	*sp;	/* at or before where state is to be saved or
410e2f9
! 				   NULL */
410e2f9
  {
410e2f9
      int		i;
410e2f9
      synstate_T	*p;
410e2f9
      bufstate_T	*bp;
410e2f9
      stateitem_T	*cur_si;
410e2f9
! 
410e2f9
!     if (sp == NULL)
410e2f9
! 	sp = syn_stack_find_entry(current_lnum);
410e2f9
  
410e2f9
      /*
410e2f9
       * If the current state contains a start or end pattern that continues
410e2f9
--- 1356,1368 ----
410e2f9
   * The current state must be valid for the start of the current_lnum line!
410e2f9
   */
410e2f9
      static synstate_T *
410e2f9
! store_current_state()
410e2f9
  {
410e2f9
      int		i;
410e2f9
      synstate_T	*p;
410e2f9
      bufstate_T	*bp;
410e2f9
      stateitem_T	*cur_si;
410e2f9
!     synstate_T	*sp = syn_stack_find_entry(current_lnum);
410e2f9
  
410e2f9
      /*
410e2f9
       * If the current state contains a start or end pattern that continues
410e2f9
***************
410e2f9
*** 1667,1673 ****
410e2f9
  	     * Store the current state in b_sst_array[] for later use.
410e2f9
  	     */
410e2f9
  	    ++current_lnum;
410e2f9
! 	    (void)store_current_state(NULL);
410e2f9
  	}
410e2f9
      }
410e2f9
  
410e2f9
--- 1666,1672 ----
410e2f9
  	     * Store the current state in b_sst_array[] for later use.
410e2f9
  	     */
410e2f9
  	    ++current_lnum;
410e2f9
! 	    (void)store_current_state();
410e2f9
  	}
410e2f9
      }
410e2f9
  
410e2f9
*** ../vim-7.1.226/src/version.c	Sun Jan 13 17:11:25 2008
410e2f9
--- src/version.c	Sun Jan 13 17:37:10 2008
410e2f9
***************
410e2f9
*** 668,669 ****
410e2f9
--- 668,671 ----
410e2f9
  {   /* Add new patch number below this line */
410e2f9
+ /**/
410e2f9
+     227,
410e2f9
  /**/
410e2f9
410e2f9
-- 
410e2f9
Dreams are free, but there's a small charge for alterations.
410e2f9
410e2f9
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
410e2f9
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
410e2f9
\\\        download, build and distribute -- http://www.A-A-P.org        ///
410e2f9
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///