patch 9.1.0166: Internal error with blockwise getregion() in another buffer
Problem: Internal error with blockwise getregion() in another buffer Solution: Also change curwin->w_buffer when changing curbuf (zeertzjq) closes: #14179 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
cb942cc4ca
commit
5406eb8722
@ -5494,10 +5494,10 @@ f_getregion(typval_T *argvars, typval_T *rettv)
|
|||||||
int fnum1 = -1, fnum2 = -1;
|
int fnum1 = -1, fnum2 = -1;
|
||||||
pos_T p1, p2;
|
pos_T p1, p2;
|
||||||
char_u *type;
|
char_u *type;
|
||||||
buf_T *save_curbuf = curbuf;
|
buf_T *save_curbuf;
|
||||||
buf_T *findbuf = curbuf;
|
buf_T *findbuf;
|
||||||
char_u default_type[] = "v";
|
char_u default_type[] = "v";
|
||||||
int save_virtual = -1;
|
int save_virtual;
|
||||||
int l;
|
int l;
|
||||||
int region_type = -1;
|
int region_type = -1;
|
||||||
int is_select_exclusive;
|
int is_select_exclusive;
|
||||||
@ -5542,16 +5542,12 @@ f_getregion(typval_T *argvars, typval_T *rettv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fnum1 != 0)
|
findbuf = fnum1 != 0 ? buflist_findnr(fnum1) : curbuf;
|
||||||
{
|
|
||||||
findbuf = buflist_findnr(fnum1);
|
|
||||||
// buffer not loaded
|
|
||||||
if (findbuf == NULL || findbuf->b_ml.ml_mfp == NULL)
|
if (findbuf == NULL || findbuf->b_ml.ml_mfp == NULL)
|
||||||
{
|
{
|
||||||
emsg(_(e_buffer_is_not_loaded));
|
emsg(_(e_buffer_is_not_loaded));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (p1.lnum < 1 || p1.lnum > findbuf->b_ml.ml_line_count)
|
if (p1.lnum < 1 || p1.lnum > findbuf->b_ml.ml_line_count)
|
||||||
{
|
{
|
||||||
@ -5574,7 +5570,9 @@ f_getregion(typval_T *argvars, typval_T *rettv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save_curbuf = curbuf;
|
||||||
curbuf = findbuf;
|
curbuf = findbuf;
|
||||||
|
curwin->w_buffer = curbuf;
|
||||||
save_virtual = virtual_op;
|
save_virtual = virtual_op;
|
||||||
virtual_op = virtual_active();
|
virtual_op = virtual_active();
|
||||||
|
|
||||||
@ -5677,9 +5675,8 @@ f_getregion(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curbuf != save_curbuf)
|
|
||||||
curbuf = save_curbuf;
|
curbuf = save_curbuf;
|
||||||
|
curwin->w_buffer = curbuf;
|
||||||
virtual_op = save_virtual;
|
virtual_op = save_virtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1768,11 +1768,11 @@ func Test_visual_getregion()
|
|||||||
for type in ['v', 'V', "\<C-V>"]
|
for type in ['v', 'V', "\<C-V>"]
|
||||||
for exclusive in [v:false, v:true]
|
for exclusive in [v:false, v:true]
|
||||||
call assert_equal(range(10)->mapnew('string(v:val)'),
|
call assert_equal(range(10)->mapnew('string(v:val)'),
|
||||||
\ getregion([g:buf, 1, 1, 0], [g:buf, 10, 2, 0]),
|
\ getregion([g:buf, 1, 1, 0], [g:buf, 10, 2, 0],
|
||||||
\ {'type': type, 'exclusive': exclusive })
|
\ {'type': type, 'exclusive': exclusive }))
|
||||||
call assert_equal(range(10)->mapnew('string(v:val)'),
|
call assert_equal(range(10)->mapnew('string(v:val)'),
|
||||||
\ getregion([g:buf, 10, 2, 0], [g:buf, 1, 1, 0]),
|
\ getregion([g:buf, 10, 2, 0], [g:buf, 1, 1, 0],
|
||||||
\ {'type': type, 'exclusive': exclusive })
|
\ {'type': type, 'exclusive': exclusive }))
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|||||||
@ -704,6 +704,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 */
|
||||||
|
/**/
|
||||||
|
166,
|
||||||
/**/
|
/**/
|
||||||
165,
|
165,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user