diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-07 16:55:32 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-07 16:55:32 +0000 |
commit | b2d85e3784ac89f5209489844c1ee0f54d117abb (patch) | |
tree | 045fb2891c5912b3afa7a7b27223fe8de62eea1e /src/indent.c | |
parent | cb1956d6f2aece8ad93e19e5d4c7e0b5e405f056 (diff) | |
download | vim-git-b2d85e3784ac89f5209489844c1ee0f54d117abb.tar.gz |
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrongv8.2.4029
Problem: Debugging NFA regexp my crash, cached indent may be wrong.
Solution: Fix some debug warnings in the NFA regexp code. Make sure log_fd
is set when used. Fix breakindent and indent caching. (Christian
Brabandt, closes #9482)
Diffstat (limited to 'src/indent.c')
-rw-r--r-- | src/indent.c | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/src/indent.c b/src/indent.c index 4a8b36725..b74bae6e6 100644 --- a/src/indent.c +++ b/src/indent.c @@ -915,13 +915,15 @@ get_breakindent_win( win_T *wp, char_u *line) // start of the line { - static int prev_indent = 0; // cached indent value - static long prev_ts = 0L; // cached tabstop value - static char_u *prev_line = NULL; // cached pointer to line + static int prev_indent = 0; // cached indent value + static long prev_ts = 0L; // cached tabstop value + static char_u *prev_line = NULL; // cached pointer to line static varnumber_T prev_tick = 0; // changedtick of cached value # ifdef FEAT_VARTABS - static int *prev_vts = NULL; // cached vartabs values + static int *prev_vts = NULL; // cached vartabs values # endif + static int prev_list = 0; // cached list value + static int prev_listopt = 0; // cached w_p_briopt_list value int bri = 0; // window width minus window margin space, i.e. what rests for text const int eff_wwidth = wp->w_width @@ -929,9 +931,10 @@ get_breakindent_win( && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) ? number_width(wp) + 1 : 0); - // used cached indent, unless pointer or 'tabstop' changed + // used cached indent, unless line, 'tabstop' or briopt_list changed if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts || prev_tick != CHANGEDTICK(wp->w_buffer) + || prev_listopt != wp->w_briopt_list # ifdef FEAT_VARTABS || prev_vts != wp->w_buffer->b_p_vts_array # endif @@ -949,6 +952,28 @@ get_breakindent_win( prev_indent = get_indent_str(line, (int)wp->w_buffer->b_p_ts, wp->w_p_list); # endif + prev_listopt = wp->w_briopt_list; + // add additional indent for numbered lists + if (wp->w_briopt_list != 0) + { + regmatch_T regmatch; + + regmatch.regprog = vim_regcomp(curbuf->b_p_flp, + RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT); + + if (regmatch.regprog != NULL) + { + regmatch.rm_ic = FALSE; + if (vim_regexec(®match, line, 0)) + { + if (wp->w_briopt_list > 0) + prev_list = wp->w_briopt_list; + else + prev_list = (*regmatch.endp - *regmatch.startp); + } + vim_regfree(regmatch.regprog); + } + } } bri = prev_indent + wp->w_briopt_shift; @@ -958,22 +983,10 @@ get_breakindent_win( // add additional indent for numbered lists if (wp->w_briopt_list != 0) { - regmatch_T regmatch; - - regmatch.regprog = vim_regcomp(curbuf->b_p_flp, - RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT); - if (regmatch.regprog != NULL) - { - regmatch.rm_ic = FALSE; - if (vim_regexec(®match, line, 0)) - { - if (wp->w_briopt_list > 0) - bri += wp->w_briopt_list; - else - bri = (*regmatch.endp - *regmatch.startp); - } - vim_regfree(regmatch.regprog); - } + if (wp->w_briopt_list > 0) + bri += prev_list; + else + bri = prev_list; } // indent minus the length of the showbreak string |