To: vim-dev@vim.org Subject: Patch 6.0.044 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.044 Problem: Using a "containedin" list for a syntax item doesn't work for an item that doesn't have a "contains" argument. Also, "containedin" doesn't ignore a transparent item. (Timo Frenay) Solution: When there is a "containedin" argument somewhere, always check for contained items. Don't check for the transparent item but the item it's contained in. Files: src/structs.h, src/syntax.c *** ../vim60.43/src/structs.h Sun Oct 28 21:15:32 2001 --- src/structs.h Wed Oct 31 10:34:45 2001 *************** *** 1018,1023 **** --- 1018,1025 ---- int b_syn_ic; /* ignore case for :syn cmds */ garray_T b_syn_patterns; /* table for syntax patterns */ garray_T b_syn_clusters; /* table for syntax clusters */ + int b_syn_containedin; /* TRUE when there is an item with a + "containedin" argument */ int b_syn_sync_flags; /* flags about how to sync */ short b_syn_sync_id; /* group to sync on */ long b_syn_sync_minlines; /* minimal sync lines offset */ *** ../vim60.43/src/syntax.c Mon Oct 22 18:52:01 2001 --- src/syntax.c Wed Oct 31 11:11:24 2001 *************** *** 174,179 **** --- 174,180 ---- #define HL_FOLD 0x2000 /* define fold */ #define HL_EXTEND 0x4000 /* ignore a keepend */ #define HL_MATCHCONT 0x8000 /* match continued from previous line */ + #define HL_TRANS_CONT 0x10000 /* transparent item without contains arg */ #define SYN_ITEMS(buf) ((synpat_T *)((buf)->b_syn_patterns.ga_data)) *************** *** 1772,1784 **** * 1. Check for a current state. * Only when there is no current state, or if the current state may * contain other things, we need to check for keywords and patterns. */ if (current_state.ga_len) cur_si = &CUR_STATE(current_state.ga_len - 1); else cur_si = NULL; ! if (cur_si == NULL || cur_si->si_cont_list != NULL) { /* * 2. Check for keywords, if on a keyword char after a non-keyword --- 1773,1788 ---- * 1. Check for a current state. * Only when there is no current state, or if the current state may * contain other things, we need to check for keywords and patterns. + * Always need to check for contained items if some item has the + * "containedin" argument (takes extra time!). */ if (current_state.ga_len) cur_si = &CUR_STATE(current_state.ga_len - 1); else cur_si = NULL; ! if (curbuf->b_syn_containedin || cur_si == NULL ! || cur_si->si_cont_list != NULL) { /* * 2. Check for keywords, if on a keyword char after a non-keyword *************** *** 2387,2393 **** --- 2391,2400 ---- sip->si_attr = CUR_STATE(idx - 1).si_attr; sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id; if (sip->si_cont_list == NULL) + { + sip->si_flags |= HL_TRANS_CONT; sip->si_cont_list = CUR_STATE(idx - 1).si_cont_list; + } } } } *************** *** 3001,3006 **** --- 3008,3014 ---- int i; curbuf->b_syn_ic = FALSE; /* Use case, by default */ + curbuf->b_syn_containedin = FALSE; /* free the keywords */ free_keywtab(buf->b_keywtab); *************** *** 3884,3889 **** --- 3892,3899 ---- ktab->k_syn.inc_tag = current_syn_inc_tag; ktab->flags = flags; ktab->k_syn.cont_in_list = copy_id_list(cont_in_list); + if (cont_in_list != NULL) + curbuf->b_syn_containedin = TRUE; ktab->next_list = copy_id_list(next_list); if (curbuf->b_syn_ic) *************** *** 4397,4402 **** --- 4407,4414 ---- SYN_ITEMS(curbuf)[idx].sp_sync_idx = sync_idx; SYN_ITEMS(curbuf)[idx].sp_cont_list = cont_list; SYN_ITEMS(curbuf)[idx].sp_syn.cont_in_list = cont_in_list; + if (cont_in_list != NULL) + curbuf->b_syn_containedin = TRUE; SYN_ITEMS(curbuf)[idx].sp_next_list = next_list; ++curbuf->b_syn_patterns.ga_len; --curbuf->b_syn_patterns.ga_room; *************** *** 4637,4642 **** --- 4649,4656 ---- SYN_ITEMS(curbuf)[idx].sp_cont_list = cont_list; SYN_ITEMS(curbuf)[idx].sp_syn.cont_in_list = cont_in_list; + if (cont_in_list != NULL) + curbuf->b_syn_containedin = TRUE; SYN_ITEMS(curbuf)[idx].sp_next_list = next_list; } ++curbuf->b_syn_patterns.ga_len; *************** *** 5516,5527 **** int r; /* If spp has a "containedin" list and "cur_si" is in it, return TRUE. */ ! if (cur_si != NULL ! && ssp->cont_in_list != NULL ! && in_id_list(NULL, ssp->cont_in_list, &(SYN_ITEMS(syn_buf)[cur_si->si_idx].sp_syn), SYN_ITEMS(syn_buf)[cur_si->si_idx].sp_flags & HL_CONTAINED)) return TRUE; /* * If list is ID_LIST_ALL, we are in a transparent item that isn't --- 5530,5548 ---- int r; /* If spp has a "containedin" list and "cur_si" is in it, return TRUE. */ ! if (cur_si != NULL && ssp->cont_in_list != NULL) ! { ! /* Ignore transparent items without a contains argument. */ ! while (cur_si->si_flags & HL_TRANS_CONT) ! --cur_si; ! if (in_id_list(NULL, ssp->cont_in_list, &(SYN_ITEMS(syn_buf)[cur_si->si_idx].sp_syn), SYN_ITEMS(syn_buf)[cur_si->si_idx].sp_flags & HL_CONTAINED)) return TRUE; + } + + if (list == NULL) + return FALSE; /* * If list is ID_LIST_ALL, we are in a transparent item that isn't *** ../vim60.43/src/version.c Wed Oct 31 10:12:03 2001 --- src/version.c Wed Oct 31 11:14:14 2001 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 44, /**/ -- Citizens are not allowed to attend a movie house or theater nor ride in a public streetcar within at least four hours after eating garlic. [real standing law in Indiana, United States of America] /// 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 ///