Skip to content

Commit 58adb14

Browse files
committed
patch 7.4.1108
Problem: Expanding "~" halfway a file name. Solution: Handle the file name as one name. (Marco Hinz) Add a test. Closes #564.
1 parent da440d2 commit 58adb14

7 files changed

Lines changed: 44 additions & 24 deletions

File tree

src/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,12 +1975,15 @@ test1 \
19751975
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
19761976
test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \
19771977
test90 test91 test92 test93 test94 test95 test96 test97 test98 test99 \
1978-
test100 test101 test102 test103 test104 test105 test106 test107:
1978+
test100 test101 test102 test103 test104 test105 test106 test107 test108:
19791979
cd testdir; rm -f [email protected]; $(MAKE) -f Makefile [email protected] VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
19801980

19811981
test_assert \
19821982
test_backspace_opt \
19831983
test_cdo \
1984+
test_cursor_func \
1985+
test_delete \
1986+
test_expand \
19841987
test_hardcopy \
19851988
test_increment \
19861989
test_lispwords \

src/misc2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5543,7 +5543,7 @@ find_file_in_path_option(ptr, len, options, first, path_option,
55435543
/* copy file name into NameBuff, expanding environment variables */
55445544
save_char = ptr[len];
55455545
ptr[len] = NUL;
5546-
expand_env(ptr, NameBuff, MAXPATHL);
5546+
expand_env_esc(ptr, NameBuff, MAXPATHL, FALSE, TRUE, NULL);
55475547
ptr[len] = save_char;
55485548

55495549
vim_free(ff_file_to_find);

src/testdir/test27.in

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/testdir/test27.ok

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/testdir/test_alot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
source test_backspace_opt.vim
55
source test_cursor_func.vim
66
source test_delete.vim
7+
source test_expand.vim
78
source test_lispwords.vim
89
source test_menu.vim
910
source test_searchpos.vim

src/testdir/test_expand.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
" Test for expanding file names
2+
3+
func Test_with_directories()
4+
call mkdir('Xdir1')
5+
call mkdir('Xdir2')
6+
call mkdir('Xdir3')
7+
cd Xdir3
8+
call mkdir('Xdir4')
9+
cd ..
10+
11+
split Xdir1/file
12+
call setline(1, ['a', 'b'])
13+
w
14+
w Xdir3/Xdir4/file
15+
close
16+
17+
next Xdir?/*/file
18+
call assert_equal('Xdir3/Xdir4/file', expand('%'))
19+
next! Xdir?/*/nofile
20+
call assert_equal('Xdir?/*/nofile', expand('%'))
21+
22+
call delete('Xdir1', 'rf')
23+
call delete('Xdir2', 'rf')
24+
call delete('Xdir3', 'rf')
25+
endfunc
26+
27+
func Test_with_tilde()
28+
let dir = getcwd()
29+
call mkdir('Xdir ~ dir')
30+
call assert_true(isdirectory('Xdir ~ dir'))
31+
cd Xdir\ ~\ dir
32+
call assert_true(getcwd() =~ 'Xdir \~ dir')
33+
exe 'cd ' . fnameescape(dir)
34+
call delete('Xdir ~ dir', 'd')
35+
call assert_false(isdirectory('Xdir ~ dir'))
36+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1108,
744746
/**/
745747
1107,
746748
/**/

0 commit comments

Comments
 (0)