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)
diff --git a/src/eval.c b/src/eval.c
index ca1c55b..87da4f3 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1940,7 +1940,7 @@
// avoid 'l' flag in 'cpoptions'
save_cpo = p_cpo;
- p_cpo = (char_u *)"";
+ p_cpo = empty_option;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL)
{
@@ -6200,8 +6200,14 @@
if (p_cpo == empty_option)
p_cpo = save_cpo;
else
+ {
// 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);
+ }
return ret;
}