comparison src/syntax.c @ 12510:7a887dccd13a

patch 8.0.1133: syntax timeout not used correctly commit https://github.com/vim/vim/commit/f3d769a585040ac47f7054057758809024ef6377 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 22 13:44:56 2017 +0200 patch 8.0.1133: syntax timeout not used correctly Problem: Syntax timeout not used correctly. Solution: Do not pass the timeout to syntax_start() but set it explicitly. (Yasuhiro Matsumoto, closes #2139)
author Christian Brabandt <cb@256bit.org>
date Fri, 22 Sep 2017 13:45:05 +0200
parents 3f16cf18386c
children b85c981b3a8e
comparison
equal deleted inserted replaced
12509:1fd4594eb74a 12510:7a887dccd13a
366 */ 366 */
367 static win_T *syn_win; /* current window for highlighting */ 367 static win_T *syn_win; /* current window for highlighting */
368 static buf_T *syn_buf; /* current buffer for highlighting */ 368 static buf_T *syn_buf; /* current buffer for highlighting */
369 static synblock_T *syn_block; /* current buffer for highlighting */ 369 static synblock_T *syn_block; /* current buffer for highlighting */
370 #ifdef FEAT_RELTIME 370 #ifdef FEAT_RELTIME
371 static proftime_T *syn_tm; 371 static proftime_T *syn_tm; /* timeout limit */
372 #endif 372 #endif
373 static linenr_T current_lnum = 0; /* lnum of current state */ 373 static linenr_T current_lnum = 0; /* lnum of current state */
374 static colnr_T current_col = 0; /* column of current state */ 374 static colnr_T current_col = 0; /* column of current state */
375 static int current_state_stored = 0; /* TRUE if stored current state 375 static int current_state_stored = 0; /* TRUE if stored current state
376 * after setting current_finished */ 376 * after setting current_finished */
487 static void syn_cmd_sync(exarg_T *eap, int syncing); 487 static void syn_cmd_sync(exarg_T *eap, int syncing);
488 static int get_id_list(char_u **arg, int keylen, short **list, int skip); 488 static int get_id_list(char_u **arg, int keylen, short **list, int skip);
489 static void syn_combine_list(short **clstr1, short **clstr2, int list_op); 489 static void syn_combine_list(short **clstr1, short **clstr2, int list_op);
490 static void syn_incl_toplevel(int id, int *flagsp); 490 static void syn_incl_toplevel(int id, int *flagsp);
491 491
492 #if defined(FEAT_RELTIME) || defined(PROTO)
493 /*
494 * Set the timeout used for syntax highlighting.
495 * Use NULL to reset, no timeout.
496 */
497 void
498 syn_set_timeout(proftime_T *tm)
499 {
500 syn_tm = tm;
501 }
502 #endif
503
492 /* 504 /*
493 * Start the syntax recognition for a line. This function is normally called 505 * Start the syntax recognition for a line. This function is normally called
494 * from the screen updating, once for each displayed line. 506 * from the screen updating, once for each displayed line.
495 * The buffer is remembered in syn_buf, because get_syntax_attr() doesn't get 507 * The buffer is remembered in syn_buf, because get_syntax_attr() doesn't get
496 * it. Careful: curbuf and curwin are likely to point to another buffer and 508 * it. Careful: curbuf and curwin are likely to point to another buffer and
497 * window. 509 * window.
498 */ 510 */
499 void 511 void
500 syntax_start(win_T *wp, linenr_T lnum, proftime_T *syntax_tm UNUSED) 512 syntax_start(win_T *wp, linenr_T lnum)
501 { 513 {
502 synstate_T *p; 514 synstate_T *p;
503 synstate_T *last_valid = NULL; 515 synstate_T *last_valid = NULL;
504 synstate_T *last_min_valid = NULL; 516 synstate_T *last_min_valid = NULL;
505 synstate_T *sp, *prev = NULL; 517 synstate_T *sp, *prev = NULL;
525 syn_buf = wp->w_buffer; 537 syn_buf = wp->w_buffer;
526 syn_block = wp->w_s; 538 syn_block = wp->w_s;
527 } 539 }
528 changedtick = CHANGEDTICK(syn_buf); 540 changedtick = CHANGEDTICK(syn_buf);
529 syn_win = wp; 541 syn_win = wp;
530 #ifdef FEAT_RELTIME
531 syn_tm = syntax_tm;
532 #endif
533 542
534 /* 543 /*
535 * Allocate syntax stack when needed. 544 * Allocate syntax stack when needed.
536 */ 545 */
537 syn_stack_alloc(); 546 syn_stack_alloc();
6567 /* When the position is not after the current position and in the same 6576 /* When the position is not after the current position and in the same
6568 * line of the same buffer, need to restart parsing. */ 6577 * line of the same buffer, need to restart parsing. */
6569 if (wp->w_buffer != syn_buf 6578 if (wp->w_buffer != syn_buf
6570 || lnum != current_lnum 6579 || lnum != current_lnum
6571 || col < current_col) 6580 || col < current_col)
6572 syntax_start(wp, lnum, NULL); 6581 syntax_start(wp, lnum);
6573 else if (wp->w_buffer == syn_buf 6582 else if (wp->w_buffer == syn_buf
6574 && lnum == current_lnum 6583 && lnum == current_lnum
6575 && col > current_col) 6584 && col > current_col)
6576 /* next_match may not be correct when moving around, e.g. with the 6585 /* next_match may not be correct when moving around, e.g. with the
6577 * "skip" expression in searchpair() */ 6586 * "skip" expression in searchpair() */
6643 # ifdef SYN_TIME_LIMIT 6652 # ifdef SYN_TIME_LIMIT
6644 && !wp->w_s->b_syn_slow 6653 && !wp->w_s->b_syn_slow
6645 # endif 6654 # endif
6646 ) 6655 )
6647 { 6656 {
6648 syntax_start(wp, lnum, NULL); 6657 syntax_start(wp, lnum);
6649 6658
6650 for (i = 0; i < current_state.ga_len; ++i) 6659 for (i = 0; i < current_state.ga_len; ++i)
6651 if (CUR_STATE(i).si_flags & HL_FOLD) 6660 if (CUR_STATE(i).si_flags & HL_FOLD)
6652 ++level; 6661 ++level;
6653 } 6662 }
7004 #endif 7013 #endif
7005 #ifdef FEAT_MENU 7014 #ifdef FEAT_MENU
7006 CENT("ToolbarLine term=underline ctermbg=LightGrey", 7015 CENT("ToolbarLine term=underline ctermbg=LightGrey",
7007 "ToolbarLine term=underline ctermbg=LightGrey guibg=LightGrey"), 7016 "ToolbarLine term=underline ctermbg=LightGrey guibg=LightGrey"),
7008 CENT("ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey", 7017 CENT("ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey",
7009 "ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold guifg=White guibg=DarkGrey"), 7018 "ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold guifg=White guibg=Grey40"),
7010 #endif 7019 #endif
7011 NULL 7020 NULL
7012 }; 7021 };
7013 7022
7014 /* Default colors only used with a dark background. */ 7023 /* Default colors only used with a dark background. */
7100 CENT("StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen", 7109 CENT("StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen",
7101 "StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen guifg=bg guibg=LightGreen"), 7110 "StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen guifg=bg guibg=LightGreen"),
7102 #endif 7111 #endif
7103 #ifdef FEAT_MENU 7112 #ifdef FEAT_MENU
7104 CENT("ToolbarLine term=underline ctermbg=DarkGrey", 7113 CENT("ToolbarLine term=underline ctermbg=DarkGrey",
7105 "ToolbarLine term=underline ctermbg=DarkGrey guibg=DarkGrey"), 7114 "ToolbarLine term=underline ctermbg=DarkGrey guibg=Grey50"),
7106 CENT("ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey", 7115 CENT("ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey",
7107 "ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey gui=bold guifg=Black guibg=LightGrey"), 7116 "ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey gui=bold guifg=Black guibg=LightGrey"),
7108 #endif 7117 #endif
7109 NULL 7118 NULL
7110 }; 7119 };