Patch 9.0.0016

8 views
Skip to first unread message

Bram Moolenaar

unread,
Jul 1, 2022, 8:16:11 AM7/1/22
to vim...@googlegroups.com

Patch 9.0.0016
Problem: Comparing line pointer for 'breakindent' is not reliable.
Solution: Make a copy of the line.
Files: src/indent.c, src/testdir/test_breakindent.vim


*** ../vim-9.0.0015/src/indent.c 2022-06-22 19:57:42.000000000 +0100
--- src/indent.c 2022-07-01 13:11:15.784487734 +0100
***************
*** 924,930 ****
{
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
--- 924,931 ----
{
static int prev_indent = 0; // cached indent value
static long prev_ts = 0L; // cached tabstop value
! 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,961 ****
? number_width(wp) + 1 : 0);

// used cached indent, unless
! // - line pointer changed
// - 'tabstop' changed
// - 'briopt_list changed' changed or
// - 'formatlistpattern' 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
! || (prev_flp == NULL
! || (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))
# ifdef FEAT_VARTABS
|| prev_vts != wp->w_buffer->b_p_vts_array
# endif
)
{
! prev_line = line;
prev_ts = wp->w_buffer->b_p_ts;
prev_tick = CHANGEDTICK(wp->w_buffer);
# ifdef FEAT_VARTABS
--- 942,969 ----
? number_width(wp) + 1 : 0);

// used cached indent, unless
! // - buffer changed
// - 'tabstop' changed
+ // - buffer was changed
// - 'briopt_list changed' changed or
// - 'formatlistpattern' changed
! // - 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_line == NULL || STRCMP(prev_line, line) != 0
# ifdef FEAT_VARTABS
|| prev_vts != wp->w_buffer->b_p_vts_array
# endif
)
{
! 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
*** ../vim-9.0.0015/src/testdir/test_breakindent.vim 2022-06-30 22:13:56.208846322 +0100
--- src/testdir/test_breakindent.vim 2022-07-01 13:13:31.692266260 +0100
***************
*** 716,724 ****
endfunc

func Test_breakindent20_list()
- " FIXME - this should not matter
- call test_override('alloc_lines', 0)
-
call s:test_windows('setl breakindent breakindentopt= linebreak')
" default:
call setline(1, [' 1. Congress shall make no law',
--- 716,721 ----
***************
*** 802,813 ****
call s:compare_lines(expect, lines)
" check formatlistpat indent with different list levels
let &l:flp = '^\s*\*\+\s\+'
- redraw!
%delete _
call setline(1, ['* Congress shall make no law',
\ '*** Congress shall make no law',
\ '**** Congress shall make no law'])
norm! 1gg
let expect = [
\ "* Congress shall ",
\ " make no law ",
--- 799,810 ----
call s:compare_lines(expect, lines)
" check formatlistpat indent with different list levels
let &l:flp = '^\s*\*\+\s\+'
%delete _
call setline(1, ['* Congress shall make no law',
\ '*** Congress shall make no law',
\ '**** Congress shall make no law'])
norm! 1gg
+ redraw!
let expect = [
\ "* Congress shall ",
\ " make no law ",
***************
*** 835,843 ****
let lines = s:screen_lines2(1, 6, 20)
call s:compare_lines(expect, lines)
call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&')
-
- " FIXME - this should not matter
- call test_override('alloc_lines', 1)
endfunc

" The following used to crash Vim. This is fixed by 8.2.3391.
--- 832,837 ----
***************
*** 881,889 ****
endfunc

func Test_no_spurious_match()
- " FIXME - fails under valgrind - this should not matter - timing issue?
- call test_override('alloc_lines', 0)
-
let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50))
call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls')
let @/ = '\%>3v[y]'
--- 875,880 ----
***************
*** 893,900 ****
" cleanup
set hls&vim
bwipeout!
- " FIXME - this should not matter
- call test_override('alloc_lines', 1)
endfunc

func Test_no_extra_indent()
--- 884,889 ----
*** ../vim-9.0.0015/src/version.c 2022-07-01 12:13:12.463831288 +0100
--- src/version.c 2022-07-01 13:08:45.416741322 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 16,
/**/

--
hundred-and-one symptoms of being an internet addict:
30. Even though you died last week, you've managed to retain OPS on your
favorite IRC channel.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages