Patch 8.0.1133
Problem:    Syntax timeout not used correctly.
Solution:   Do not pass the timeout to syntax_start() but set it explicitly.
            (Yasuhiro Matsumoto, closes #2139)
Files:      src/proto/syntax.pro, src/screen.c, src/syntax.c


*** ../vim-8.0.1132/src/proto/syntax.pro        2017-09-17 23:02:17.164074471 
+0200
--- src/proto/syntax.pro        2017-09-22 13:36:30.474457936 +0200
***************
*** 1,5 ****
  /* syntax.c */
! void syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm);
  void syn_stack_free_all(synblock_T *block);
  void syn_stack_apply_changes(buf_T *buf);
  void syntax_end_parsing(linenr_T lnum);
--- 1,6 ----
  /* syntax.c */
! void syn_set_timeout(proftime_T *tm);
! void syntax_start(win_T *wp, linenr_T lnum);
  void syn_stack_free_all(synblock_T *block);
  void syn_stack_apply_changes(buf_T *buf);
  void syntax_end_parsing(linenr_T lnum);
*** ../vim-8.0.1132/src/screen.c        2017-09-17 23:02:17.180074376 +0200
--- src/screen.c        2017-09-22 13:35:13.054931200 +0200
***************
*** 131,137 ****
  static void fill_foldcolumn(char_u *p, win_T *wp, int closed, linenr_T lnum);
  static void copy_text_attr(int off, char_u *buf, int len, int attr);
  #endif
! static int win_line(win_T *, linenr_T, int, int, int nochange, proftime_T 
*syntax_tm);
  static int char_needs_redraw(int off_from, int off_to, int cols);
  static void draw_vsep_win(win_T *wp, int row);
  #ifdef FEAT_STL_OPT
--- 131,137 ----
  static void fill_foldcolumn(char_u *p, win_T *wp, int closed, linenr_T lnum);
  static void copy_text_attr(int off, char_u *buf, int len, int attr);
  #endif
! static int win_line(win_T *, linenr_T, int, int, int nochange);
  static int char_needs_redraw(int off_from, int off_to, int cols);
  static void draw_vsep_win(win_T *wp, int row);
  #ifdef FEAT_STL_OPT
***************
*** 930,935 ****
--- 930,936 ----
  #ifdef SYN_TIME_LIMIT
        /* Set the time limit to 'redrawtime'. */
        profile_setlimit(p_rdt, &syntax_tm);
+       syn_set_timeout(&syntax_tm);
  #endif
        update_prepare();
  
***************
*** 944,956 ****
                start_search_hl();
                prepare_search_hl(wp, lnum);
  # endif
!               win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE,
! #ifdef SYN_TIME_LIMIT
!                       &syntax_tm
! #else
!                       NULL
! #endif
!                       );
  # if defined(FEAT_SEARCH_EXTRA)
                end_search_hl();
  # endif
--- 945,951 ----
                start_search_hl();
                prepare_search_hl(wp, lnum);
  # endif
!               win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE);
  # if defined(FEAT_SEARCH_EXTRA)
                end_search_hl();
  # endif
***************
*** 960,965 ****
--- 955,964 ----
        }
  
        update_finish();
+ 
+ #ifdef SYN_TIME_LIMIT
+       syn_set_timeout(NULL);
+ #endif
      }
      need_cursor_line_redraw = FALSE;
  }
***************
*** 1805,1810 ****
--- 1804,1810 ----
  #ifdef SYN_TIME_LIMIT
      /* Set the time limit to 'redrawtime'. */
      profile_setlimit(p_rdt, &syntax_tm);
+     syn_set_timeout(&syntax_tm);
  #endif
  #ifdef FEAT_FOLDING
      win_foldinfo.fi_level = 0;
***************
*** 2109,2121 ****
                /*
                 * Display one line.
                 */
!               row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0,
! #ifdef SYN_TIME_LIMIT
!                       &syntax_tm
! #else
!                       NULL
! #endif
!                       );
  
  #ifdef FEAT_FOLDING
                wp->w_lines[idx].wl_folded = FALSE;
--- 2109,2115 ----
                /*
                 * Display one line.
                 */
!               row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0);
  
  #ifdef FEAT_FOLDING
                wp->w_lines[idx].wl_folded = FALSE;
***************
*** 2275,2280 ****
--- 2269,2278 ----
        win_draw_end(wp, '~', ' ', row, wp->w_height, HLF_EOB);
      }
  
+ #ifdef SYN_TIME_LIMIT
+     syn_set_timeout(NULL);
+ #endif
+ 
      /* Reset the type of redrawing required, the window has been updated. */
      wp->w_redr_type = 0;
  #ifdef FEAT_DIFF
***************
*** 3000,3007 ****
      linenr_T  lnum,
      int               startrow,
      int               endrow,
!     int               nochange UNUSED,        /* not updating for changed 
text */
!     proftime_T        *syntax_tm UNUSED)
  {
      int               col = 0;                /* visual column on screen */
      unsigned  off;                    /* offset in ScreenLines/ScreenAttrs */
--- 2998,3004 ----
      linenr_T  lnum,
      int               startrow,
      int               endrow,
!     int               nochange UNUSED)        /* not updating for changed 
text */
  {
      int               col = 0;                /* visual column on screen */
      unsigned  off;                    /* offset in ScreenLines/ScreenAttrs */
***************
*** 3216,3222 ****
         * error, stop syntax highlighting. */
        save_did_emsg = did_emsg;
        did_emsg = FALSE;
!       syntax_start(wp, lnum, syntax_tm);
        if (did_emsg)
            wp->w_s->b_syn_error = TRUE;
        else
--- 3213,3219 ----
         * error, stop syntax highlighting. */
        save_did_emsg = did_emsg;
        did_emsg = FALSE;
!       syntax_start(wp, lnum);
        if (did_emsg)
            wp->w_s->b_syn_error = TRUE;
        else
***************
*** 3614,3620 ****
  # ifdef FEAT_SYN_HL
            /* Need to restart syntax highlighting for this line. */
            if (has_syntax)
!               syntax_start(wp, lnum, syntax_tm);
  # endif
        }
  #endif
--- 3611,3617 ----
  # ifdef FEAT_SYN_HL
            /* Need to restart syntax highlighting for this line. */
            if (has_syntax)
!               syntax_start(wp, lnum);
  # endif
        }
  #endif
*** ../vim-8.0.1132/src/syntax.c        2017-09-17 23:02:17.164074471 +0200
--- src/syntax.c        2017-09-22 13:36:15.442549826 +0200
***************
*** 368,374 ****
  static buf_T  *syn_buf;               /* current buffer for highlighting */
  static synblock_T *syn_block;         /* current buffer for highlighting */
  #ifdef FEAT_RELTIME
! static proftime_T *syn_tm;
  #endif
  static linenr_T current_lnum = 0;     /* lnum of current state */
  static colnr_T        current_col = 0;        /* column of current state */
--- 368,374 ----
  static buf_T  *syn_buf;               /* current buffer for highlighting */
  static synblock_T *syn_block;         /* current buffer for highlighting */
  #ifdef FEAT_RELTIME
! static proftime_T *syn_tm;            /* timeout limit */
  #endif
  static linenr_T current_lnum = 0;     /* lnum of current state */
  static colnr_T        current_col = 0;        /* column of current state */
***************
*** 489,494 ****
--- 489,506 ----
  static void syn_combine_list(short **clstr1, short **clstr2, int list_op);
  static void syn_incl_toplevel(int id, int *flagsp);
  
+ #if defined(FEAT_RELTIME) || defined(PROTO)
+ /*
+  * Set the timeout used for syntax highlighting.
+  * Use NULL to reset, no timeout.
+  */
+     void
+ syn_set_timeout(proftime_T *tm)
+ {
+     syn_tm = tm;
+ }
+ #endif
+ 
  /*
   * Start the syntax recognition for a line.  This function is normally called
   * from the screen updating, once for each displayed line.
***************
*** 497,503 ****
   * window.
   */
      void
! syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm UNUSED)
  {
      synstate_T        *p;
      synstate_T        *last_valid = NULL;
--- 509,515 ----
   * window.
   */
      void
! syntax_start(win_T *wp, linenr_T lnum)
  {
      synstate_T        *p;
      synstate_T        *last_valid = NULL;
***************
*** 527,535 ****
      }
      changedtick = CHANGEDTICK(syn_buf);
      syn_win = wp;
- #ifdef FEAT_RELTIME
-     syn_tm = syntax_tm;
- #endif
  
      /*
       * Allocate syntax stack when needed.
--- 539,544 ----
***************
*** 6569,6575 ****
      if (wp->w_buffer != syn_buf
            || lnum != current_lnum
            || col < current_col)
!       syntax_start(wp, lnum, NULL);
      else if (wp->w_buffer == syn_buf
            && lnum == current_lnum
            && col > current_col)
--- 6578,6584 ----
      if (wp->w_buffer != syn_buf
            || lnum != current_lnum
            || col < current_col)
!       syntax_start(wp, lnum);
      else if (wp->w_buffer == syn_buf
            && lnum == current_lnum
            && col > current_col)
***************
*** 6645,6651 ****
  # endif
            )
      {
!       syntax_start(wp, lnum, NULL);
  
        for (i = 0; i < current_state.ga_len; ++i)
            if (CUR_STATE(i).si_flags & HL_FOLD)
--- 6654,6660 ----
  # endif
            )
      {
!       syntax_start(wp, lnum);
  
        for (i = 0; i < current_state.ga_len; ++i)
            if (CUR_STATE(i).si_flags & HL_FOLD)
***************
*** 7006,7012 ****
      CENT("ToolbarLine term=underline ctermbg=LightGrey",
         "ToolbarLine term=underline ctermbg=LightGrey guibg=LightGrey"),
      CENT("ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey",
!        "ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold 
guifg=White guibg=DarkGrey"),
  #endif
      NULL
  };
--- 7015,7021 ----
      CENT("ToolbarLine term=underline ctermbg=LightGrey",
         "ToolbarLine term=underline ctermbg=LightGrey guibg=LightGrey"),
      CENT("ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey",
!        "ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold 
guifg=White guibg=Grey40"),
  #endif
      NULL
  };
***************
*** 7102,7108 ****
  #endif
  #ifdef FEAT_MENU
      CENT("ToolbarLine term=underline ctermbg=DarkGrey",
!        "ToolbarLine term=underline ctermbg=DarkGrey guibg=DarkGrey"),
      CENT("ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey",
         "ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey gui=bold 
guifg=Black guibg=LightGrey"),
  #endif
--- 7111,7117 ----
  #endif
  #ifdef FEAT_MENU
      CENT("ToolbarLine term=underline ctermbg=DarkGrey",
!        "ToolbarLine term=underline ctermbg=DarkGrey guibg=Grey50"),
      CENT("ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey",
         "ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey gui=bold 
guifg=Black guibg=LightGrey"),
  #endif
*** ../vim-8.0.1132/src/version.c       2017-09-21 22:46:43.750047949 +0200
--- src/version.c       2017-09-22 13:34:45.243101215 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1133,
  /**/

-- 
If Apple would build a car...
... it would be powered by the sun, be reliable, five times
as fast and twice as easy to drive; but would only run on
five percent of the roads.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui