comparison src/indent.c @ 27128:164d59ddd48a v8.2.4093

patch 8.2.4093: cached breakindent values not initialized properly Commit: https://github.com/vim/vim/commit/c53b467473160b5cfce77277fbae414bf43e66ce Author: Christian Brabandt <cb@256bit.org> Date: Sat Jan 15 10:01:05 2022 +0000 patch 8.2.4093: cached breakindent values not initialized properly Problem: Cached breakindent values not initialized properly. Solution: Initialize and cache formatlistpat. (Christian Brabandt, closes #9526, closes #9512)
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Jan 2022 11:15:03 +0100
parents 8c0730eca2ce
children 748ab01dbdc5
comparison
equal deleted inserted replaced
27127:33918a28ec46 27128:164d59ddd48a
922 # ifdef FEAT_VARTABS 922 # ifdef FEAT_VARTABS
923 static int *prev_vts = NULL; // cached vartabs values 923 static int *prev_vts = NULL; // cached vartabs values
924 # endif 924 # endif
925 static int prev_list = 0; // cached list value 925 static int prev_list = 0; // cached list value
926 static int prev_listopt = 0; // cached w_p_briopt_list value 926 static int prev_listopt = 0; // cached w_p_briopt_list value
927 // cached formatlistpat value
928 static char_u *prev_flp = NULL;
927 int bri = 0; 929 int bri = 0;
928 // window width minus window margin space, i.e. what rests for text 930 // window width minus window margin space, i.e. what rests for text
929 const int eff_wwidth = wp->w_width 931 const int eff_wwidth = wp->w_width
930 - ((wp->w_p_nu || wp->w_p_rnu) 932 - ((wp->w_p_nu || wp->w_p_rnu)
931 && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) 933 && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
932 ? number_width(wp) + 1 : 0); 934 ? number_width(wp) + 1 : 0);
933 935
934 // used cached indent, unless line, 'tabstop' or briopt_list changed 936 // used cached indent, unless
937 // - line pointer changed
938 // - 'tabstop' changed
939 // - 'briopt_list changed' changed or
940 // - 'formatlistpattern' changed
935 if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts 941 if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
936 || prev_tick != CHANGEDTICK(wp->w_buffer) 942 || prev_tick != CHANGEDTICK(wp->w_buffer)
937 || prev_listopt != wp->w_briopt_list 943 || prev_listopt != wp->w_briopt_list
944 || (prev_flp == NULL
945 || (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))
938 # ifdef FEAT_VARTABS 946 # ifdef FEAT_VARTABS
939 || prev_vts != wp->w_buffer->b_p_vts_array 947 || prev_vts != wp->w_buffer->b_p_vts_array
940 # endif 948 # endif
941 ) 949 )
942 { 950 {
951 # else 959 # else
952 prev_indent = get_indent_str(line, 960 prev_indent = get_indent_str(line,
953 (int)wp->w_buffer->b_p_ts, wp->w_p_list); 961 (int)wp->w_buffer->b_p_ts, wp->w_p_list);
954 # endif 962 # endif
955 prev_listopt = wp->w_briopt_list; 963 prev_listopt = wp->w_briopt_list;
964 prev_list = 0;
965 vim_free(prev_flp);
966 prev_flp = vim_strsave(get_flp_value(wp->w_buffer));
956 // add additional indent for numbered lists 967 // add additional indent for numbered lists
957 if (wp->w_briopt_list != 0) 968 if (wp->w_briopt_list != 0)
958 { 969 {
959 regmatch_T regmatch; 970 regmatch_T regmatch;
960 971
961 regmatch.regprog = vim_regcomp(curbuf->b_p_flp, 972 regmatch.regprog = vim_regcomp(prev_flp,
962 RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT); 973 RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT);
963 974
964 if (regmatch.regprog != NULL) 975 if (regmatch.regprog != NULL)
965 { 976 {
966 regmatch.rm_ic = FALSE; 977 regmatch.rm_ic = FALSE;
967 if (vim_regexec(&regmatch, line, 0)) 978 if (vim_regexec(&regmatch, line, 0))