• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision336c99d14cc549b2609c73baf34fab7d64bb9e03 (tree)
l'heure2022-07-01 21:30:03
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

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.

Change Summary

Modification

diff -r ab6b4e105fa5 -r 336c99d14cc5 src/indent.c
--- a/src/indent.c Fri Jul 01 13:15:05 2022 +0200
+++ b/src/indent.c Fri Jul 01 14:30:03 2022 +0200
@@ -924,7 +924,8 @@
924924 {
925925 static int prev_indent = 0; // cached indent value
926926 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"
928929 static varnumber_T prev_tick = 0; // changedtick of cached value
929930 # ifdef FEAT_VARTABS
930931 static int *prev_vts = NULL; // cached vartabs values
@@ -941,21 +942,28 @@
941942 ? number_width(wp) + 1 : 0);
942943
943944 // used cached indent, unless
944- // - line pointer changed
945+ // - buffer changed
945946 // - 'tabstop' changed
947+ // - buffer was changed
946948 // - 'briopt_list changed' changed or
947949 // - '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
949954 || prev_tick != CHANGEDTICK(wp->w_buffer)
950955 || prev_listopt != wp->w_briopt_list
951- || (prev_flp == NULL
952- || (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))
956+ || prev_flp == NULL
957+ || STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0
958+ || prev_line == NULL || STRCMP(prev_line, line) != 0
953959 # ifdef FEAT_VARTABS
954960 || prev_vts != wp->w_buffer->b_p_vts_array
955961 # endif
956962 )
957963 {
958- prev_line = line;
964+ prev_fnum = wp->w_buffer->b_fnum;
965+ vim_free(prev_line);
966+ prev_line = vim_strsave(line);
959967 prev_ts = wp->w_buffer->b_p_ts;
960968 prev_tick = CHANGEDTICK(wp->w_buffer);
961969 # ifdef FEAT_VARTABS
diff -r ab6b4e105fa5 -r 336c99d14cc5 src/testdir/test_breakindent.vim
--- a/src/testdir/test_breakindent.vim Fri Jul 01 13:15:05 2022 +0200
+++ b/src/testdir/test_breakindent.vim Fri Jul 01 14:30:03 2022 +0200
@@ -716,9 +716,6 @@
716716 endfunc
717717
718718 func Test_breakindent20_list()
719- " FIXME - this should not matter
720- call test_override('alloc_lines', 0)
721-
722719 call s:test_windows('setl breakindent breakindentopt= linebreak')
723720 " default:
724721 call setline(1, [' 1. Congress shall make no law',
@@ -802,12 +799,12 @@
802799 call s:compare_lines(expect, lines)
803800 " check formatlistpat indent with different list levels
804801 let &l:flp = '^\s*\*\+\s\+'
805- redraw!
806802 %delete _
807803 call setline(1, ['* Congress shall make no law',
808804 \ '*** Congress shall make no law',
809805 \ '**** Congress shall make no law'])
810806 norm! 1gg
807+ redraw!
811808 let expect = [
812809 \ "* Congress shall ",
813810 \ " make no law ",
@@ -835,9 +832,6 @@
835832 let lines = s:screen_lines2(1, 6, 20)
836833 call s:compare_lines(expect, lines)
837834 call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&')
838-
839- " FIXME - this should not matter
840- call test_override('alloc_lines', 1)
841835 endfunc
842836
843837 " The following used to crash Vim. This is fixed by 8.2.3391.
@@ -881,9 +875,6 @@
881875 endfunc
882876
883877 func Test_no_spurious_match()
884- " FIXME - fails under valgrind - this should not matter - timing issue?
885- call test_override('alloc_lines', 0)
886-
887878 let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50))
888879 call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls')
889880 let @/ = '\%>3v[y]'
@@ -893,8 +884,6 @@
893884 " cleanup
894885 set hls&vim
895886 bwipeout!
896- " FIXME - this should not matter
897- call test_override('alloc_lines', 1)
898887 endfunc
899888
900889 func Test_no_extra_indent()
diff -r ab6b4e105fa5 -r 336c99d14cc5 src/version.c
--- a/src/version.c Fri Jul 01 13:15:05 2022 +0200
+++ b/src/version.c Fri Jul 01 14:30:03 2022 +0200
@@ -736,6 +736,8 @@
736736 static int included_patches[] =
737737 { /* Add new patch number below this line */
738738 /**/
739+ 16,
740+/**/
739741 15,
740742 /**/
741743 14,
Afficher sur ancien navigateur de dépôt.