To: vim-dev@vim.org Subject: Patch 6.0.143 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.143 Problem: When a syntax item includes a line break in a pattern, the syntax may not be updated properly when making a change. Solution: Add the "linebreaks" argument to ":syn sync". Files: runtime/doc/syntax.txt, src/screen.c, src/structs.h, src/syntax.c *** ../vim60.142/runtime/doc/syntax.txt Tue Sep 25 21:40:39 2001 --- runtime/doc/syntax.txt Thu Jan 17 15:21:41 2002 *************** *** 1895,1901 **** need to make sure syncing takes care of this. Example (match a character constant): > ! :syntax match Character /'.'/s+1e-1 < DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end* --- 1962,1968 ---- need to make sure syncing takes care of this. Example (match a character constant): > ! :syntax match Character /'.'/hs=s+1,he=e-1 < DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end* *************** *** 2594,2603 **** include". ============================================================================== ! 10. Synchronizing *:syn-sync* *E403* *E404* Vim wants to be able to start redrawing in any position in the document. To ! make this possible it needs to know the syntax item at the position where redrawing starts. :sy[ntax] sync [ccomment [group-name] | minlines={N} | ...] --- 2661,2670 ---- include". ============================================================================== ! 10. Synchronizing *:syn-sync* *E403* *E404* Vim wants to be able to start redrawing in any position in the document. To ! make this possible it needs to know the syntax state at the position where redrawing starts. :sy[ntax] sync [ccomment [group-name] | minlines={N} | ...] *************** *** 2626,2631 **** --- 2693,2709 ---- adding "minlines". This is useful if you have few things to sync on and a slow machine. Example: > :syntax sync ccomment maxlines=500 + < + *:syn-sync-linebreaks* + When using a pattern that matches multiple lines, a change in one line may + cause a pattern to no longer match in a previous line. This means has to + start above where the change was made. How many lines can be specified with + the "linebreaks" argument. For example, when a pattern may include one line + break use this: > + :syntax sync linebreaks=1 + The result is that redrawing always starts at least one line before where a + change was made. The default value for "linebreaks" is zero. Usually the + value for "minlines" is bigger than "linebreaks". First syncing method: *:syn-sync-first* *** ../vim60.142/src/screen.c Wed Jan 16 12:28:44 2002 --- src/screen.c Thu Jan 17 15:23:49 2002 *************** *** 823,829 **** --- 823,837 ---- if (buf->b_mod_set) { if (mod_top == 0 || mod_top > buf->b_mod_top) + { mod_top = buf->b_mod_top; + #ifdef FEAT_SYN_HL + /* Need to redraw lines above the change that may be included + * in a pattern match. */ + if (syntax_present(buf)) + mod_top -= buf->b_syn_sync_linebreaks; + #endif + } if (mod_bot == 0 || mod_bot < buf->b_mod_bot) mod_bot = buf->b_mod_bot; *** ../vim60.142/src/structs.h Tue Jan 15 14:34:37 2002 --- src/structs.h Thu Jan 17 15:22:02 2002 *************** *** 1049,1054 **** --- 1049,1055 ---- short b_syn_sync_id; /* group to sync on */ long b_syn_sync_minlines; /* minimal sync lines offset */ long b_syn_sync_maxlines; /* maximal sync lines offset */ + long b_syn_sync_linebreaks; /* offset for multi-line pattern */ char_u *b_syn_linecont_pat; /* line continuation pattern */ regprog_T *b_syn_linecont_prog; /* line continuation program */ int b_syn_linecont_ic; /* ignore-case flag for above */ *** ../vim60.142/src/syntax.c Thu Nov 1 12:22:41 2001 --- src/syntax.c Thu Jan 17 15:23:39 2002 *************** *** 383,388 **** --- 383,389 ---- static void syn_cmd_onoff __ARGS((exarg_T *eap, char *name)); static void syn_cmd_list __ARGS((exarg_T *eap, int syncing)); static void syn_lines_msg __ARGS((void)); + static void syn_match_msg __ARGS((void)); static void syn_list_one __ARGS((int id, int syncing, int link_only)); static void syn_list_cluster __ARGS((int id)); static void put_id_list __ARGS((char_u *name, short *list, int attr)); *************** *** 1149,1155 **** prev = NULL; for (p = buf->b_sst_first; p != NULL; ) { ! if (p->sst_lnum > buf->b_mod_top) { n = p->sst_lnum + buf->b_mod_xlines; if (n <= buf->b_mod_bot) --- 1150,1156 ---- prev = NULL; for (p = buf->b_sst_first; p != NULL; ) { ! if (p->sst_lnum + syn_buf->b_syn_sync_linebreaks > buf->b_mod_top) { n = p->sst_lnum + buf->b_mod_xlines; if (n <= buf->b_mod_bot) *************** *** 3029,3034 **** --- 3030,3036 ---- buf->b_syn_sync_flags = 0; buf->b_syn_sync_minlines = 0; buf->b_syn_sync_maxlines = 0; + buf->b_syn_sync_linebreaks = 0; vim_free(buf->b_syn_linecont_prog); buf->b_syn_linecont_prog = NULL; *************** *** 3059,3064 **** --- 3061,3067 ---- curbuf->b_syn_sync_flags = 0; curbuf->b_syn_sync_minlines = 0; curbuf->b_syn_sync_maxlines = 0; + curbuf->b_syn_sync_linebreaks = 0; vim_free(curbuf->b_syn_linecont_prog); curbuf->b_syn_linecont_prog = NULL; *************** *** 3346,3353 **** if (curbuf->b_syn_sync_flags & SF_CCOMMENT) { MSG_PUTS(_("syncing on C-style comments")); ! if (curbuf->b_syn_sync_minlines || curbuf->b_syn_sync_maxlines) ! syn_lines_msg(); return; } else if (!(curbuf->b_syn_sync_flags & SF_MATCH)) --- 3349,3356 ---- if (curbuf->b_syn_sync_flags & SF_CCOMMENT) { MSG_PUTS(_("syncing on C-style comments")); ! syn_lines_msg(); ! syn_match_msg(); return; } else if (!(curbuf->b_syn_sync_flags & SF_MATCH)) *************** *** 3359,3372 **** MSG_PUTS(_("syncing starts ")); msg_outnum(curbuf->b_syn_sync_minlines); MSG_PUTS(_(" lines before top line")); } return; } MSG_PUTS_TITLE(_("\n--- Syntax sync items ---")); ! if (curbuf->b_syn_sync_minlines || curbuf->b_syn_sync_maxlines) { MSG_PUTS(_("\nsyncing on items")); syn_lines_msg(); } } else --- 3362,3379 ---- MSG_PUTS(_("syncing starts ")); msg_outnum(curbuf->b_syn_sync_minlines); MSG_PUTS(_(" lines before top line")); + syn_match_msg(); } return; } MSG_PUTS_TITLE(_("\n--- Syntax sync items ---")); ! if (curbuf->b_syn_sync_minlines > 0 ! || curbuf->b_syn_sync_maxlines > 0 ! || curbuf->b_syn_sync_linebreaks > 0) { MSG_PUTS(_("\nsyncing on items")); syn_lines_msg(); + syn_match_msg(); } } else *************** *** 3414,3433 **** static void syn_lines_msg() { ! MSG_PUTS("; "); ! if (curbuf->b_syn_sync_minlines) { ! MSG_PUTS(_("minimal ")); ! msg_outnum(curbuf->b_syn_sync_minlines); ! if (curbuf->b_syn_sync_maxlines) ! MSG_PUTS(", "); } ! if (curbuf->b_syn_sync_maxlines) { ! MSG_PUTS(_("maximal ")); ! msg_outnum(curbuf->b_syn_sync_maxlines); } - MSG_PUTS(_(" lines before top line")); } static int last_matchgroup; --- 3421,3454 ---- static void syn_lines_msg() { ! if (curbuf->b_syn_sync_maxlines > 0 || curbuf->b_syn_sync_minlines > 0) { ! MSG_PUTS("; "); ! if (curbuf->b_syn_sync_minlines > 0) ! { ! MSG_PUTS(_("minimal ")); ! msg_outnum(curbuf->b_syn_sync_minlines); ! if (curbuf->b_syn_sync_maxlines) ! MSG_PUTS(", "); ! } ! if (curbuf->b_syn_sync_maxlines > 0) ! { ! MSG_PUTS(_("maximal ")); ! msg_outnum(curbuf->b_syn_sync_maxlines); ! } ! MSG_PUTS(_(" lines before top line")); } ! } ! ! static void ! syn_match_msg() ! { ! if (curbuf->b_syn_sync_linebreaks > 0) { ! MSG_PUTS(_("; match ")); ! msg_outnum(curbuf->b_syn_sync_linebreaks); ! MSG_PUTS(_(" line breaks")); } } static int last_matchgroup; *************** *** 5187,5196 **** } else if ( STRNCMP(key, "LINES", 5) == 0 || STRNCMP(key, "MINLINES", 8) == 0 ! || STRNCMP(key, "MAXLINES", 8) == 0) { ! if (key[0] == 'L') arg_end = key + 6; else arg_end = key + 9; if (arg_end[-1] != '=' || !isdigit(*arg_end)) --- 5208,5220 ---- } else if ( STRNCMP(key, "LINES", 5) == 0 || STRNCMP(key, "MINLINES", 8) == 0 ! || STRNCMP(key, "MAXLINES", 8) == 0 ! || STRNCMP(key, "LINEBREAKS", 10) == 0) { ! if (key[4] == 'S') arg_end = key + 6; + else if (key[0] == 'L') + arg_end = key + 11; else arg_end = key + 9; if (arg_end[-1] != '=' || !isdigit(*arg_end)) *************** *** 5201,5207 **** n = getdigits(&arg_end); if (!eap->skip) { ! if (key[1] == 'A') curbuf->b_syn_sync_maxlines = n; else curbuf->b_syn_sync_minlines = n; --- 5225,5233 ---- n = getdigits(&arg_end); if (!eap->skip) { ! if (key[4] == 'B') ! curbuf->b_syn_sync_linebreaks = n; ! else if (key[1] == 'A') curbuf->b_syn_sync_maxlines = n; else curbuf->b_syn_sync_minlines = n; *** ../vim60.142/src/version.c Thu Jan 17 12:12:55 2002 --- src/version.c Thu Jan 17 15:29:23 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 143, /**/ -- Q: What is the difference betwee open-source and commercial software? A: If you have a problem with commercial software you can call a phone number and they will tell you it might be solved in a future version. For open-source sofware there isn't a phone number to call, but you get the solution within a day. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///