mirror of
https://github.com/vim/vim.git
synced 2025-08-26 20:03:41 -04:00
patch 9.1.1572: expanding $var does not escape whitespace for 'path'
Problem: expanding $var does not escape whitespace for 'path' Solution: Escape whitespace when expanding 'path' option. (Miguel Barro) closes: #17801 Signed-off-by: Miguel Barro <miguel.barro@live.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
239c4e4abe
commit
8b004081c4
12
src/option.c
12
src/option.c
@ -2927,14 +2927,16 @@ option_expand(int opt_idx, char_u *val)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Expanding this with NameBuff, expand_env() must not be passed IObuff.
|
* Expanding this with NameBuff, expand_env() must not be passed IObuff.
|
||||||
* Escape spaces when expanding 'tags', they are used to separate file
|
* Escape spaces when expanding 'tags' or 'path', they are used to separate
|
||||||
* names.
|
* file names.
|
||||||
* For 'spellsuggest' expand after "file:".
|
* For 'spellsuggest' expand after "file:".
|
||||||
*/
|
*/
|
||||||
expand_env_esc(val, NameBuff, MAXPATHL,
|
char_u ** var = (char_u **)options[opt_idx].var;
|
||||||
(char_u **)options[opt_idx].var == &p_tags, FALSE,
|
int esc = var == &p_tags || var == &p_path;
|
||||||
|
|
||||||
|
expand_env_esc(val, NameBuff, MAXPATHL, esc, FALSE,
|
||||||
#ifdef FEAT_SPELL
|
#ifdef FEAT_SPELL
|
||||||
(char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
|
var == &p_sps ? (char_u *)"file:" :
|
||||||
#endif
|
#endif
|
||||||
NULL);
|
NULL);
|
||||||
if (STRCMP(NameBuff, val) == 0) // they are the same
|
if (STRCMP(NameBuff, val) == 0) // they are the same
|
||||||
|
@ -834,5 +834,36 @@ func Test_findfunc_callback()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test using environment variables with spaces
|
||||||
|
func Test_path_env_variable_with_whitespaces()
|
||||||
|
let save_path = &path
|
||||||
|
defer execute('let &path = save_path')
|
||||||
|
|
||||||
|
let $testdir = 'Xpath with some whites'
|
||||||
|
call mkdir($testdir, 'R')
|
||||||
|
|
||||||
|
" Check direct usage yields the same result that autocomplete
|
||||||
|
call feedkeys(':set path=$testdir' .. "\<C-A>\<CR>", 'xt')
|
||||||
|
let auto_testpath = &path
|
||||||
|
" include autocomplete suffix
|
||||||
|
exe "set path=$testdir" .. "/"
|
||||||
|
call assert_equal(auto_testpath, &path)
|
||||||
|
|
||||||
|
" Check a file can be found using environment variables
|
||||||
|
let expanded_test_path = expand('$testdir/test.txt')
|
||||||
|
call writefile(['testing...'], expanded_test_path)
|
||||||
|
|
||||||
|
" hinting an environment variable path
|
||||||
|
call assert_equal(expanded_test_path, findfile('test.txt', $test_dir))
|
||||||
|
|
||||||
|
" using 'path' option with an environment variable
|
||||||
|
set path=$testdir
|
||||||
|
call assert_equal(expanded_test_path, findfile('test.txt'))
|
||||||
|
|
||||||
|
" using :find instead of findfile()
|
||||||
|
find test.txt
|
||||||
|
call assert_equal(expanded_test_path, expand('%:.'))
|
||||||
|
enew
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -719,6 +719,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 */
|
||||||
|
/**/
|
||||||
|
1572,
|
||||||
/**/
|
/**/
|
||||||
1571,
|
1571,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user