Mercurial > vim
comparison src/indent.c @ 29346:336c99d14cc5 v9.0.0016
patch 9.0.0016: comparing line pointer for 'breakindent' is not reliable
Commit: https://github.com/vim/vim/commit/c2a79b87fc31080ba24394c0b30bab45f1bea852
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 1 13:15:35 2022 +0100
patch 9.0.0016: comparing line pointer for 'breakindent' is not reliable
Problem: Comparing line pointer for 'breakindent' is not reliable.
Solution: Make a copy of the line.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 01 Jul 2022 14:30:03 +0200 |
parents | 9bc63b4f9c33 |
children | 057c26b5c33a |
comparison
equal
deleted
inserted
replaced
29345:ab6b4e105fa5 | 29346:336c99d14cc5 |
---|---|
922 win_T *wp, | 922 win_T *wp, |
923 char_u *line) // start of the line | 923 char_u *line) // start of the line |
924 { | 924 { |
925 static int prev_indent = 0; // cached indent value | 925 static int prev_indent = 0; // cached indent value |
926 static long prev_ts = 0L; // cached tabstop value | 926 static long prev_ts = 0L; // cached tabstop value |
927 static char_u *prev_line = NULL; // cached pointer to line | 927 static int prev_fnum = 0; // cached buffer number |
928 static char_u *prev_line = NULL; // cached copy of "line" | |
928 static varnumber_T prev_tick = 0; // changedtick of cached value | 929 static varnumber_T prev_tick = 0; // changedtick of cached value |
929 # ifdef FEAT_VARTABS | 930 # ifdef FEAT_VARTABS |
930 static int *prev_vts = NULL; // cached vartabs values | 931 static int *prev_vts = NULL; // cached vartabs values |
931 # endif | 932 # endif |
932 static int prev_list = 0; // cached list value | 933 static int prev_list = 0; // cached list value |
939 - ((wp->w_p_nu || wp->w_p_rnu) | 940 - ((wp->w_p_nu || wp->w_p_rnu) |
940 && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) | 941 && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) |
941 ? number_width(wp) + 1 : 0); | 942 ? number_width(wp) + 1 : 0); |
942 | 943 |
943 // used cached indent, unless | 944 // used cached indent, unless |
944 // - line pointer changed | 945 // - buffer changed |
945 // - 'tabstop' changed | 946 // - 'tabstop' changed |
947 // - buffer was changed | |
946 // - 'briopt_list changed' changed or | 948 // - 'briopt_list changed' changed or |
947 // - 'formatlistpattern' changed | 949 // - 'formatlistpattern' changed |
948 if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts | 950 // - line changed |
951 // - 'vartabs' changed | |
952 if (prev_fnum != wp->w_buffer->b_fnum | |
953 || prev_ts != wp->w_buffer->b_p_ts | |
949 || prev_tick != CHANGEDTICK(wp->w_buffer) | 954 || prev_tick != CHANGEDTICK(wp->w_buffer) |
950 || prev_listopt != wp->w_briopt_list | 955 || prev_listopt != wp->w_briopt_list |
951 || (prev_flp == NULL | 956 || prev_flp == NULL |
952 || (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0)) | 957 || STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0 |
958 || prev_line == NULL || STRCMP(prev_line, line) != 0 | |
953 # ifdef FEAT_VARTABS | 959 # ifdef FEAT_VARTABS |
954 || prev_vts != wp->w_buffer->b_p_vts_array | 960 || prev_vts != wp->w_buffer->b_p_vts_array |
955 # endif | 961 # endif |
956 ) | 962 ) |
957 { | 963 { |
958 prev_line = line; | 964 prev_fnum = wp->w_buffer->b_fnum; |
965 vim_free(prev_line); | |
966 prev_line = vim_strsave(line); | |
959 prev_ts = wp->w_buffer->b_p_ts; | 967 prev_ts = wp->w_buffer->b_p_ts; |
960 prev_tick = CHANGEDTICK(wp->w_buffer); | 968 prev_tick = CHANGEDTICK(wp->w_buffer); |
961 # ifdef FEAT_VARTABS | 969 # ifdef FEAT_VARTABS |
962 prev_vts = wp->w_buffer->b_p_vts_array; | 970 prev_vts = wp->w_buffer->b_p_vts_array; |
963 if (wp->w_briopt_vcol == 0) | 971 if (wp->w_briopt_vcol == 0) |