comparison src/testdir/test_expand.vim @ 34511:5397ce113043 v9.1.0161

patch 9.1.0161: expand() removes slash after env variable that ends with colon Commit: https://github.com/vim/vim/commit/13a014452a7a020a119ac555a690c65b41f3126d Author: zeertzjq <zeertzjq@outlook.com> Date: Sat Mar 9 17:44:46 2024 +0100 patch 9.1.0161: expand() removes slash after env variable that ends with colon Problem: expand() removes a slash after an environment variable that ends with a colon on Windows. Solution: Check the correct char for a colon (zeertzjq) closes: #14161 Note: Vim still removes the path-separator at the end, if another path separator follows directly after it, e.g. on: ``` echo $FOO='/usr/' echo expand('$FOO/bar') == '/usr/bar' ``` see: ,----[ misc1.c:1630 ] | // if var[] ends in a path separator and tail[] starts | // with it, skip a character | if (after_pathsep(dst, dst + c) | #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) | && (dst == save_dst || dst[-1] != ':') | #endif | && vim_ispathsep(*tail)) | ++tail; `---- Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 09 Mar 2024 18:15:02 +0100
parents dbec60b8c253
children
comparison
equal deleted inserted replaced
34510:408e9818595d 34511:5397ce113043
47 split ~ 47 split ~
48 call assert_equal('~', expand('%')) 48 call assert_equal('~', expand('%'))
49 call assert_notequal(expand('%:p'), expand('~/')) 49 call assert_notequal(expand('%:p'), expand('~/'))
50 call assert_match('\~', expand('%:p')) 50 call assert_match('\~', expand('%:p'))
51 bwipe! 51 bwipe!
52 endfunc
53
54 func Test_expand_env_pathsep()
55 let $FOO = './foo'
56 call assert_equal('./foo/bar', expand('$FOO/bar'))
57 let $FOO = './foo/'
58 call assert_equal('./foo/bar', expand('$FOO/bar'))
59 let $FOO = 'C:'
60 call assert_equal('C:/bar', expand('$FOO/bar'))
61 let $FOO = 'C:/'
62 call assert_equal('C:/bar', expand('$FOO/bar'))
63
64 unlet $FOO
52 endfunc 65 endfunc
53 66
54 func Test_expandcmd() 67 func Test_expandcmd()
55 let $FOO = 'Test' 68 let $FOO = 'Test'
56 call assert_equal('e x/Test/y', expandcmd('e x/$FOO/y')) 69 call assert_equal('e x/Test/y', expandcmd('e x/$FOO/y'))