mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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.
This commit is contained in:
20
src/indent.c
20
src/indent.c
@@ -924,7 +924,8 @@ get_breakindent_win(
|
|||||||
{
|
{
|
||||||
static int prev_indent = 0; // cached indent value
|
static int prev_indent = 0; // cached indent value
|
||||||
static long prev_ts = 0L; // cached tabstop 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
|
static varnumber_T prev_tick = 0; // changedtick of cached value
|
||||||
# ifdef FEAT_VARTABS
|
# ifdef FEAT_VARTABS
|
||||||
static int *prev_vts = NULL; // cached vartabs values
|
static int *prev_vts = NULL; // cached vartabs values
|
||||||
@@ -941,21 +942,28 @@ get_breakindent_win(
|
|||||||
? number_width(wp) + 1 : 0);
|
? number_width(wp) + 1 : 0);
|
||||||
|
|
||||||
// used cached indent, unless
|
// used cached indent, unless
|
||||||
// - line pointer changed
|
// - buffer changed
|
||||||
// - 'tabstop' changed
|
// - 'tabstop' changed
|
||||||
|
// - buffer was changed
|
||||||
// - 'briopt_list changed' changed or
|
// - 'briopt_list changed' changed or
|
||||||
// - 'formatlistpattern' changed
|
// - '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_tick != CHANGEDTICK(wp->w_buffer)
|
||||||
|| prev_listopt != wp->w_briopt_list
|
|| prev_listopt != wp->w_briopt_list
|
||||||
|| (prev_flp == NULL
|
|| prev_flp == NULL
|
||||||
|| (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))
|
|| STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0
|
||||||
|
|| prev_line == NULL || STRCMP(prev_line, line) != 0
|
||||||
# ifdef FEAT_VARTABS
|
# ifdef FEAT_VARTABS
|
||||||
|| prev_vts != wp->w_buffer->b_p_vts_array
|
|| prev_vts != wp->w_buffer->b_p_vts_array
|
||||||
# endif
|
# 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_ts = wp->w_buffer->b_p_ts;
|
||||||
prev_tick = CHANGEDTICK(wp->w_buffer);
|
prev_tick = CHANGEDTICK(wp->w_buffer);
|
||||||
# ifdef FEAT_VARTABS
|
# ifdef FEAT_VARTABS
|
||||||
|
@@ -716,9 +716,6 @@ func Test_breakindent20_cpo_n_nextpage()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_breakindent20_list()
|
func Test_breakindent20_list()
|
||||||
" FIXME - this should not matter
|
|
||||||
call test_override('alloc_lines', 0)
|
|
||||||
|
|
||||||
call s:test_windows('setl breakindent breakindentopt= linebreak')
|
call s:test_windows('setl breakindent breakindentopt= linebreak')
|
||||||
" default:
|
" default:
|
||||||
call setline(1, [' 1. Congress shall make no law',
|
call setline(1, [' 1. Congress shall make no law',
|
||||||
@@ -802,12 +799,12 @@ func Test_breakindent20_list()
|
|||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
" check formatlistpat indent with different list levels
|
" check formatlistpat indent with different list levels
|
||||||
let &l:flp = '^\s*\*\+\s\+'
|
let &l:flp = '^\s*\*\+\s\+'
|
||||||
redraw!
|
|
||||||
%delete _
|
%delete _
|
||||||
call setline(1, ['* Congress shall make no law',
|
call setline(1, ['* Congress shall make no law',
|
||||||
\ '*** Congress shall make no law',
|
\ '*** Congress shall make no law',
|
||||||
\ '**** Congress shall make no law'])
|
\ '**** Congress shall make no law'])
|
||||||
norm! 1gg
|
norm! 1gg
|
||||||
|
redraw!
|
||||||
let expect = [
|
let expect = [
|
||||||
\ "* Congress shall ",
|
\ "* Congress shall ",
|
||||||
\ " make no law ",
|
\ " make no law ",
|
||||||
@@ -835,9 +832,6 @@ func Test_breakindent20_list()
|
|||||||
let lines = s:screen_lines2(1, 6, 20)
|
let lines = s:screen_lines2(1, 6, 20)
|
||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&')
|
call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&')
|
||||||
|
|
||||||
" FIXME - this should not matter
|
|
||||||
call test_override('alloc_lines', 1)
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" The following used to crash Vim. This is fixed by 8.2.3391.
|
" The following used to crash Vim. This is fixed by 8.2.3391.
|
||||||
@@ -881,9 +875,6 @@ func Test_cursor_position_with_showbreak()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_no_spurious_match()
|
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))
|
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')
|
call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls')
|
||||||
let @/ = '\%>3v[y]'
|
let @/ = '\%>3v[y]'
|
||||||
@@ -893,8 +884,6 @@ func Test_no_spurious_match()
|
|||||||
" cleanup
|
" cleanup
|
||||||
set hls&vim
|
set hls&vim
|
||||||
bwipeout!
|
bwipeout!
|
||||||
" FIXME - this should not matter
|
|
||||||
call test_override('alloc_lines', 1)
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_no_extra_indent()
|
func Test_no_extra_indent()
|
||||||
|
@@ -735,6 +735,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
16,
|
||||||
/**/
|
/**/
|
||||||
15,
|
15,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user