1
0
forked from aniani/vim

patch 9.0.0544: minor issues with setting a string option

Problem:    Minor issues with setting a string option.
Solution:   Adjust the code, add a test. (closes #11192)
This commit is contained in:
zeertzjq
2022-09-22 13:57:32 +01:00
committed by Bram Moolenaar
parent e24b5e0b0f
commit fcba86c031
3 changed files with 21 additions and 7 deletions

View File

@@ -1323,13 +1323,11 @@ do_set_string(
/* /*
* Set 'keywordprg' to ":help" if an empty * Set 'keywordprg' to ":help" if an empty
* value was passed to :set by the user. * value was passed to :set by the user.
* Misuse errbuf[] for the resulting string.
*/ */
if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' ')) if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' '))
{ {
STRCPY(errbuf, ":help");
save_arg = arg; save_arg = arg;
arg = (char_u *)errbuf; arg = (char_u *)":help";
} }
/* /*
* Convert 'backspace' number to string, for * Convert 'backspace' number to string, for
@@ -1417,7 +1415,7 @@ do_set_string(
* but do remove it for "\\\\machine\\path". * but do remove it for "\\\\machine\\path".
* The reverse is found in ExpandOldSetting(). * The reverse is found in ExpandOldSetting().
*/ */
while (*arg && !VIM_ISWHITE(*arg)) while (*arg != NUL && !VIM_ISWHITE(*arg))
{ {
int i; int i;
@@ -1565,8 +1563,8 @@ do_set_string(
} }
} }
if (save_arg != NULL) // number for 'whichwrap' if (save_arg != NULL)
arg = save_arg; arg = save_arg; // arg was temporarily changed, restore it
} }
/* /*

View File

@@ -1343,4 +1343,18 @@ func Test_switchbuf_reset()
only! only!
endfunc endfunc
" :set empty string for global 'keywordprg' falls back to ":help"
func Test_keywordprg_empty()
let k = &keywordprg
set keywordprg=man
call assert_equal('man', &keywordprg)
set keywordprg=
call assert_equal(':help', &keywordprg)
set keywordprg=man
call assert_equal('man', &keywordprg)
call assert_equal("\n keywordprg=:help", execute('set kp= kp?'))
let &keywordprg = k
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -699,6 +699,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 */
/**/
544,
/**/ /**/
543, 543,
/**/ /**/