To: vim-dev@vim.org Subject: Patch 7.1.219 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.1.219 (after 7.1.215) Problem: synstack() returns situation after the current character, can't see the state for a one-character region. Solution: Don't update ending states in the requested column. Files: runtime/doc/eval.txt, src/eval.c, src/hardcopy.c, src/proto/syntax.pro, src/screen.c, src/spell.c, src/syntax.c *** ../vim-7.1.218/runtime/doc/eval.txt Thu Jan 10 22:23:22 2008 --- runtime/doc/eval.txt Fri Jan 11 22:04:59 2008 *************** *** 1,4 **** ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 10 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 11 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 4967,4976 **** Return a |List|, which is the stack of syntax items at the position {lnum} and {col} in the current window. Each item in the List is an ID like what |synID()| returns. - The stack is the situation in between the character at "col" - and the next character. Note that a region of only one - character will not show up, it only exists inside that - character, not in between characters. The first item in the List is the outer region, following are items contained in that one. The last one is what |synID()| returns, unless not the whole item is highlighted or it is a --- 4970,4975 ---- *** ../vim-7.1.218/src/eval.c Thu Jan 10 22:23:22 2008 --- src/eval.c Fri Jan 11 21:46:12 2008 *************** *** 15725,15731 **** if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && col < (long)STRLEN(ml_get(lnum))) ! id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL); #endif rettv->vval.v_number = id; --- 15725,15731 ---- if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && col < (long)STRLEN(ml_get(lnum))) ! id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL, FALSE); #endif rettv->vval.v_number = id; *************** *** 15874,15880 **** && col >= 0 && col < (long)STRLEN(ml_get(lnum)) && rettv_list_alloc(rettv) != FAIL) { ! (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL); for (i = 0; ; ++i) { id = syn_get_stack_item(i); --- 15874,15880 ---- && col >= 0 && col < (long)STRLEN(ml_get(lnum)) && rettv_list_alloc(rettv) != FAIL) { ! (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE); for (i = 0; ; ++i) { id = syn_get_stack_item(i); *** ../vim-7.1.218/src/hardcopy.c Thu May 10 20:40:02 2007 --- src/hardcopy.c Fri Jan 11 21:46:20 2008 *************** *** 876,882 **** */ if (psettings->do_syntax) { ! id = syn_get_id(curwin, ppos->file_line, col, 1, NULL); if (id > 0) id = syn_get_final_id(id); else --- 876,882 ---- */ if (psettings->do_syntax) { ! id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, FALSE); if (id > 0) id = syn_get_final_id(id); else *** ../vim-7.1.218/src/proto/syntax.pro Thu Jan 10 22:23:22 2008 --- src/proto/syntax.pro Fri Jan 11 21:54:19 2008 *************** *** 4,10 **** void syn_stack_apply_changes __ARGS((buf_T *buf)); void syntax_end_parsing __ARGS((linenr_T lnum)); int syntax_check_changed __ARGS((linenr_T lnum)); ! int get_syntax_attr __ARGS((colnr_T col, int *can_spell)); void syntax_clear __ARGS((buf_T *buf)); void ex_syntax __ARGS((exarg_T *eap)); int syntax_present __ARGS((buf_T *buf)); --- 4,10 ---- void syn_stack_apply_changes __ARGS((buf_T *buf)); void syntax_end_parsing __ARGS((linenr_T lnum)); int syntax_check_changed __ARGS((linenr_T lnum)); ! int get_syntax_attr __ARGS((colnr_T col, int *can_spell, int keep_state)); void syntax_clear __ARGS((buf_T *buf)); void ex_syntax __ARGS((exarg_T *eap)); int syntax_present __ARGS((buf_T *buf)); *************** *** 12,18 **** void set_context_in_echohl_cmd __ARGS((expand_T *xp, char_u *arg)); void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg)); char_u *get_syntax_name __ARGS((expand_T *xp, int idx)); ! int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp)); int syn_get_stack_item __ARGS((int i)); int syn_get_foldlevel __ARGS((win_T *wp, long lnum)); void init_highlight __ARGS((int both, int reset)); --- 12,18 ---- void set_context_in_echohl_cmd __ARGS((expand_T *xp, char_u *arg)); void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg)); char_u *get_syntax_name __ARGS((expand_T *xp, int idx)); ! int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp, int keep_state)); int syn_get_stack_item __ARGS((int i)); int syn_get_foldlevel __ARGS((win_T *wp, long lnum)); void init_highlight __ARGS((int both, int reset)); *** ../vim-7.1.218/src/screen.c Thu Nov 8 21:23:34 2007 --- src/screen.c Fri Jan 11 21:48:10 2008 *************** *** 3885,3891 **** # ifdef FEAT_SPELL has_spell ? &can_spell : # endif ! NULL); if (did_emsg) { --- 3885,3891 ---- # ifdef FEAT_SPELL has_spell ? &can_spell : # endif ! NULL, FALSE); if (did_emsg) { *** ../vim-7.1.218/src/spell.c Sun Aug 5 18:32:21 2007 --- src/spell.c Fri Jan 11 21:46:50 2008 *************** *** 2146,2152 **** { col = (int)(p - buf); (void)syn_get_id(wp, lnum, (colnr_T)col, ! FALSE, &can_spell); if (!can_spell) attr = HLF_COUNT; } --- 2146,2152 ---- { col = (int)(p - buf); (void)syn_get_id(wp, lnum, (colnr_T)col, ! FALSE, &can_spell, FALSE); if (!can_spell) attr = HLF_COUNT; } *** ../vim-7.1.218/src/syntax.c Fri Jan 11 21:26:49 2008 --- src/syntax.c Sat Jan 12 16:42:25 2008 *************** *** 378,384 **** static int syn_stack_equal __ARGS((synstate_T *sp)); static void validate_current_state __ARGS((void)); static int syn_finish_line __ARGS((int syncing)); ! static int syn_current_attr __ARGS((int syncing, int displaying, int *can_spell)); static int did_match_already __ARGS((int idx, garray_T *gap)); static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si)); static void check_state_ends __ARGS((void)); --- 378,384 ---- static int syn_stack_equal __ARGS((synstate_T *sp)); static void validate_current_state __ARGS((void)); static int syn_finish_line __ARGS((int syncing)); ! static int syn_current_attr __ARGS((int syncing, int displaying, int *can_spell, int keep_state)); static int did_match_already __ARGS((int idx, garray_T *gap)); static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si)); static void check_state_ends __ARGS((void)); *************** *** 1691,1697 **** { while (!current_finished) { ! (void)syn_current_attr(syncing, FALSE, NULL); /* * When syncing, and found some item, need to check the item. */ --- 1690,1696 ---- { while (!current_finished) { ! (void)syn_current_attr(syncing, FALSE, NULL, FALSE); /* * When syncing, and found some item, need to check the item. */ *************** *** 1731,1739 **** * done. */ int ! get_syntax_attr(col, can_spell) colnr_T col; int *can_spell; { int attr = 0; --- 1730,1739 ---- * done. */ int ! get_syntax_attr(col, can_spell, keep_state) colnr_T col; int *can_spell; + int keep_state; /* keep state of char at "col" */ { int attr = 0; *************** *** 1768,1774 **** */ while (current_col <= col) { ! attr = syn_current_attr(FALSE, TRUE, can_spell); ++current_col; } --- 1768,1775 ---- */ while (current_col <= col) { ! attr = syn_current_attr(FALSE, TRUE, can_spell, ! current_col == col ? keep_state : FALSE); ++current_col; } *************** *** 1779,1788 **** * Get syntax attributes for current_lnum, current_col. */ static int ! syn_current_attr(syncing, displaying, can_spell) int syncing; /* When 1: called for syncing */ int displaying; /* result will be displayed */ int *can_spell; /* return: do spell checking */ { int syn_id; lpos_T endpos; /* was: char_u *endp; */ --- 1780,1790 ---- * Get syntax attributes for current_lnum, current_col. */ static int ! syn_current_attr(syncing, displaying, can_spell, keep_state) int syncing; /* When 1: called for syncing */ int displaying; /* result will be displayed */ int *can_spell; /* return: do spell checking */ + int keep_state; /* keep syntax stack afterwards */ { int syn_id; lpos_T endpos; /* was: char_u *endp; */ *************** *** 2298,2304 **** * may be for an empty match and a containing item might end in the * current column. */ ! if (!syncing) { check_state_ends(); if (current_state.ga_len > 0 --- 2300,2306 ---- * may be for an empty match and a containing item might end in the * current column. */ ! if (!syncing && !keep_state) { check_state_ends(); if (current_state.ga_len > 0 *************** *** 6086,6097 **** * Function called for expression evaluation: get syntax ID at file position. */ int ! syn_get_id(wp, lnum, col, trans, spellp) win_T *wp; long lnum; colnr_T col; ! int trans; /* remove transparancy */ ! int *spellp; /* return: can do spell checking */ { /* When the position is not after the current position and in the same * line of the same buffer, need to restart parsing. */ --- 6088,6100 ---- * Function called for expression evaluation: get syntax ID at file position. */ int ! syn_get_id(wp, lnum, col, trans, spellp, keep_state) win_T *wp; long lnum; colnr_T col; ! int trans; /* remove transparancy */ ! int *spellp; /* return: can do spell checking */ ! int keep_state; /* keep state of char at "col" */ { /* When the position is not after the current position and in the same * line of the same buffer, need to restart parsing. */ *************** *** 6100,6106 **** || col < current_col) syntax_start(wp, lnum); ! (void)get_syntax_attr(col, spellp); return (trans ? current_trans_id : current_id); } --- 6103,6109 ---- || col < current_col) syntax_start(wp, lnum); ! (void)get_syntax_attr(col, spellp, keep_state); return (trans ? current_trans_id : current_id); } *************** *** 6115,6122 **** syn_get_stack_item(i) int i; { ! if (i >= current_state.ga_len ) return -1; return CUR_STATE(i).si_id; } #endif --- 6118,6131 ---- syn_get_stack_item(i) int i; { ! if (i >= current_state.ga_len) ! { ! /* Need to invalidate the state, because we didn't properly finish it ! * for the last character, "keep_state" was TRUE. */ ! invalidate_current_state(); ! current_col = MAXCOL; return -1; + } return CUR_STATE(i).si_id; } #endif *** ../vim-7.1.218/src/version.c Fri Jan 11 21:26:49 2008 --- src/version.c Sat Jan 12 16:40:47 2008 *************** *** 668,669 **** --- 668,671 ---- { /* Add new patch number below this line */ + /**/ + 219, /**/ -- ARTHUR: Go on, Bors, chop its head off. BORS: Right. Silly little bleeder. One rabbit stew coming up. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///