summaryrefslogtreecommitdiffstats
path: root/src/indent.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-01 13:15:35 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-01 13:15:35 +0100
commitc2a79b87fc31080ba24394c0b30bab45f1bea852 (patch)
treed1e0d8e9da64ac9d992d13b25dc52c0cedf30780 /src/indent.c
parent79ae152697ed0dfa578cfac305d05021dec2a6bc (diff)
patch 9.0.0016: comparing line pointer for 'breakindent' is not reliablev9.0.0016
Problem: Comparing line pointer for 'breakindent' is not reliable. Solution: Make a copy of the line.
Diffstat (limited to 'src/indent.c')
-rw-r--r--src/indent.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/indent.c b/src/indent.c
index f6cfe4b2f8..61497eb4f5 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -924,7 +924,8 @@ get_breakindent_win(
{
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_fnum = 0; // cached buffer number
+ static char_u *prev_line = NULL; // cached copy of "line"
static varnumber_T prev_tick = 0; // changedtick of cached value
# ifdef FEAT_VARTABS
static int *prev_vts = NULL; // cached vartabs values
@@ -941,21 +942,28 @@ get_breakindent_win(
? number_width(wp) + 1 : 0);
// used cached indent, unless
- // - line pointer changed
+ // - buffer changed
// - 'tabstop' changed
+ // - buffer was changed
// - 'briopt_list changed' changed or
// - 'formatlistpattern' changed
- if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
+ // - line changed
+ // - 'vartabs' changed
+ if (prev_fnum != wp->w_buffer->b_fnum
+ || prev_ts != wp->w_buffer->b_p_ts
|| prev_tick != CHANGEDTICK(wp->w_buffer)
|| prev_listopt != wp->w_briopt_list
- || (prev_flp == NULL
- || (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))
+ || prev_flp == NULL
+ || STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0
+ || prev_line == NULL || STRCMP(prev_line, line) != 0
# ifdef FEAT_VARTABS
|| prev_vts != wp->w_buffer->b_p_vts_array
# endif
)
{
- prev_line = line;
+ prev_fnum = wp->w_buffer->b_fnum;
+ vim_free(prev_line);
+ prev_line = vim_strsave(line);
prev_ts = wp->w_buffer->b_p_ts;
prev_tick = CHANGEDTICK(wp->w_buffer);
# ifdef FEAT_VARTABS