mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.2289: Vim9: 'cpo' can become empty
Problem: Vim9: 'cpo' can become empty. Solution: Use empty_option instead of an empty string. Update quickfix buffer after restoring 'cpo'. (closes #7608)
This commit is contained in:
parent
5afd081cd3
commit
e5a2dc87fd
@ -1940,7 +1940,7 @@ pattern_match(char_u *pat, char_u *text, int ic)
|
|||||||
|
|
||||||
// avoid 'l' flag in 'cpoptions'
|
// avoid 'l' flag in 'cpoptions'
|
||||||
save_cpo = p_cpo;
|
save_cpo = p_cpo;
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_option;
|
||||||
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
||||||
if (regmatch.regprog != NULL)
|
if (regmatch.regprog != NULL)
|
||||||
{
|
{
|
||||||
@ -6200,8 +6200,14 @@ do_string_sub(
|
|||||||
if (p_cpo == empty_option)
|
if (p_cpo == empty_option)
|
||||||
p_cpo = save_cpo;
|
p_cpo = save_cpo;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
// Darn, evaluating {sub} expression or {expr} changed the value.
|
// Darn, evaluating {sub} expression or {expr} changed the value.
|
||||||
|
// If it's still empty it was changed and restored, need to restore in
|
||||||
|
// the complicated way.
|
||||||
|
if (*p_cpo == NUL)
|
||||||
|
set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
|
||||||
free_string_option(save_cpo);
|
free_string_option(save_cpo);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ buflist_find_by_name(char_u *name, int curtab_only)
|
|||||||
save_magic = p_magic;
|
save_magic = p_magic;
|
||||||
p_magic = TRUE;
|
p_magic = TRUE;
|
||||||
save_cpo = p_cpo;
|
save_cpo = p_cpo;
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_option;
|
||||||
|
|
||||||
buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
|
buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
|
||||||
TRUE, FALSE, curtab_only));
|
TRUE, FALSE, curtab_only));
|
||||||
|
@ -6316,7 +6316,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type)
|
|||||||
|
|
||||||
// Make 'cpoptions' empty, the 'l' flag should not be used here.
|
// Make 'cpoptions' empty, the 'l' flag should not be used here.
|
||||||
save_cpo = p_cpo;
|
save_cpo = p_cpo;
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_option;
|
||||||
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
if (type == MATCH_LIST || type == MATCH_POS)
|
if (type == MATCH_LIST || type == MATCH_POS)
|
||||||
@ -8024,8 +8024,14 @@ theend:
|
|||||||
if (p_cpo == empty_option)
|
if (p_cpo == empty_option)
|
||||||
p_cpo = save_cpo;
|
p_cpo = save_cpo;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
// Darn, evaluating the {skip} expression changed the value.
|
// Darn, evaluating the {skip} expression changed the value.
|
||||||
|
// If it's still empty it was changed and restored, need to restore in
|
||||||
|
// the complicated way.
|
||||||
|
if (*p_cpo == NUL)
|
||||||
|
set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
|
||||||
free_string_option(save_cpo);
|
free_string_option(save_cpo);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -8723,7 +8729,7 @@ f_split(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
// Make 'cpoptions' empty, the 'l' flag should not be used here.
|
// Make 'cpoptions' empty, the 'l' flag should not be used here.
|
||||||
save_cpo = p_cpo;
|
save_cpo = p_cpo;
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_option;
|
||||||
|
|
||||||
str = tv_get_string(&argvars[0]);
|
str = tv_get_string(&argvars[0]);
|
||||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||||
|
@ -1695,7 +1695,7 @@ ex_catch(exarg_T *eap)
|
|||||||
*end = NUL;
|
*end = NUL;
|
||||||
}
|
}
|
||||||
save_cpo = p_cpo;
|
save_cpo = p_cpo;
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_option;
|
||||||
// Disable error messages, it will make current_exception
|
// Disable error messages, it will make current_exception
|
||||||
// invalid.
|
// invalid.
|
||||||
++emsg_off;
|
++emsg_off;
|
||||||
|
@ -3525,7 +3525,7 @@ find_replace_callback(
|
|||||||
char_u *save_cpo = p_cpo;
|
char_u *save_cpo = p_cpo;
|
||||||
|
|
||||||
// No need to be Vi compatible here.
|
// No need to be Vi compatible here.
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_options;
|
||||||
u_undo(1);
|
u_undo(1);
|
||||||
p_cpo = save_cpo;
|
p_cpo = save_cpo;
|
||||||
gui_update_screen();
|
gui_update_screen();
|
||||||
|
@ -2475,7 +2475,7 @@ add_map(char_u *map, int mode)
|
|||||||
char_u *s;
|
char_u *s;
|
||||||
char_u *cpo_save = p_cpo;
|
char_u *cpo_save = p_cpo;
|
||||||
|
|
||||||
p_cpo = (char_u *)""; // Allow <> notation
|
p_cpo = empty_option; // Allow <> notation
|
||||||
s = vim_strsave(map);
|
s = vim_strsave(map);
|
||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
{
|
{
|
||||||
|
@ -8099,6 +8099,7 @@ ex_helpgrep(exarg_T *eap)
|
|||||||
int new_qi = FALSE;
|
int new_qi = FALSE;
|
||||||
char_u *au_name = NULL;
|
char_u *au_name = NULL;
|
||||||
char_u *lang = NULL;
|
char_u *lang = NULL;
|
||||||
|
int updated = FALSE;
|
||||||
|
|
||||||
switch (eap->cmdidx)
|
switch (eap->cmdidx)
|
||||||
{
|
{
|
||||||
@ -8150,14 +8151,24 @@ ex_helpgrep(exarg_T *eap)
|
|||||||
qfl->qf_ptr = qfl->qf_start;
|
qfl->qf_ptr = qfl->qf_start;
|
||||||
qfl->qf_index = 1;
|
qfl->qf_index = 1;
|
||||||
qf_list_changed(qfl);
|
qf_list_changed(qfl);
|
||||||
qf_update_buffer(qi, NULL);
|
updated = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_cpo == empty_option)
|
if (p_cpo == empty_option)
|
||||||
p_cpo = save_cpo;
|
p_cpo = save_cpo;
|
||||||
else
|
else
|
||||||
// Darn, some plugin changed the value.
|
{
|
||||||
|
// Darn, some plugin changed the value. If it's still empty it was
|
||||||
|
// changed and restored, need to restore in the complicated way.
|
||||||
|
if (*p_cpo == NUL)
|
||||||
|
set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
|
||||||
free_string_option(save_cpo);
|
free_string_option(save_cpo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updated)
|
||||||
|
// This may open a window and source scripts, do this after 'cpo' was
|
||||||
|
// restored.
|
||||||
|
qf_update_buffer(qi, NULL);
|
||||||
|
|
||||||
if (au_name != NULL)
|
if (au_name != NULL)
|
||||||
{
|
{
|
||||||
|
@ -5670,7 +5670,7 @@ get_syn_pattern(char_u *arg, synpat_T *ci)
|
|||||||
|
|
||||||
// Make 'cpoptions' empty, to avoid the 'l' flag
|
// Make 'cpoptions' empty, to avoid the 'l' flag
|
||||||
cpo_save = p_cpo;
|
cpo_save = p_cpo;
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_option;
|
||||||
ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC);
|
ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC);
|
||||||
p_cpo = cpo_save;
|
p_cpo = cpo_save;
|
||||||
|
|
||||||
@ -5858,7 +5858,7 @@ syn_cmd_sync(exarg_T *eap, int syncing UNUSED)
|
|||||||
|
|
||||||
// Make 'cpoptions' empty, to avoid the 'l' flag
|
// Make 'cpoptions' empty, to avoid the 'l' flag
|
||||||
cpo_save = p_cpo;
|
cpo_save = p_cpo;
|
||||||
p_cpo = (char_u *)"";
|
p_cpo = empty_option;
|
||||||
curwin->w_s->b_syn_linecont_prog =
|
curwin->w_s->b_syn_linecont_prog =
|
||||||
vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC);
|
vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC);
|
||||||
p_cpo = cpo_save;
|
p_cpo = cpo_save;
|
||||||
|
@ -702,6 +702,26 @@ func Test_helpgrep()
|
|||||||
call s:test_xhelpgrep('l')
|
call s:test_xhelpgrep('l')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
def Test_helpgrep_vim9_restore_cpo()
|
||||||
|
assert_equal('aABceFs', &cpo)
|
||||||
|
|
||||||
|
var rtp_save = &rtp
|
||||||
|
var dir = 'Xruntime/after'
|
||||||
|
&rtp ..= ',' .. dir
|
||||||
|
mkdir(dir .. '/ftplugin', 'p')
|
||||||
|
writefile(['vim9'], dir .. '/ftplugin/qf.vim')
|
||||||
|
filetype plugin on
|
||||||
|
silent helpgrep grail
|
||||||
|
cwindow
|
||||||
|
silent helpgrep grail
|
||||||
|
|
||||||
|
assert_equal('aABceFs', &cpo)
|
||||||
|
delete(dir, 'rf')
|
||||||
|
&rtp = rtp_save
|
||||||
|
cclose
|
||||||
|
helpclose
|
||||||
|
enddef
|
||||||
|
|
||||||
func Test_errortitle()
|
func Test_errortitle()
|
||||||
augroup QfBufWinEnter
|
augroup QfBufWinEnter
|
||||||
au!
|
au!
|
||||||
|
@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2289,
|
||||||
/**/
|
/**/
|
||||||
2288,
|
2288,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user