-
Notifications
You must be signed in to change notification settings - Fork 173
/
test_edit_longfilename.patch
51 lines (46 loc) · 1.77 KB
/
test_edit_longfilename.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Patch 545 doesn't have the right fix. See the pull request at
https://github.com/vim/vim/pull/1616
This fix has not yet been submitted upstream.
--- vim-8.1.1471/src/testdir/test_edit.vim 2019-06-05 22:57:04.000000000 +0000
+++ vim-8.1.1471/src/testdir/test_edit.vim 2019-06-06 07:12:05.005908740 +0000
@@ -1349,16 +1349,6 @@ func Test_edit_complete_very_long_name()
return
endif
- let dirname = getcwd() . "/Xdir"
- let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
- try
- call mkdir(longdirname, 'p')
- catch /E739:/
- " Long directory name probably not supported.
- call delete(dirname, 'rf')
- return
- endtry
-
" Try to get the Vim window position before setting 'columns', so that we can
" move the window back to where it was.
let winposx = getwinposx()
@@ -1384,7 +1374,24 @@ func Test_edit_complete_very_long_name()
set columns=2000
set noswapfile
- let longfilename = longdirname . '/' . repeat('a', 255)
+ let dirname = getcwd() . "/Xdir"
+ let path_max = str2nr(system('getconf PATH_MAX ' . getcwd()))
+ if ! path_max
+ path_max = 1024
+ endif
+ let name_max = str2nr(system('getconf NAME_MAX ' . getcwd()))
+ if ! name_max
+ name_max = 255
+ endif
+ let dirs = (path_max - len(dirname)) / name_max
+ let longdirname = dirname . repeat('/' . repeat('d', name_max), dirs)
+ " Make sure there's at least enough room for a slash and a one-character
+ " filename (plus a null byte).
+ if len(longdirname) + 3 > path_max
+ let longdirname = dirname . repeat('/' . repeat('d', name_max), dirs - 1)
+ endif
+ let longfilename = longdirname . '/' . repeat('a', path_max - len(longdirname) - 2)
+ call mkdir(longdirname, 'p')
call writefile(['Totum', 'Table'], longfilename)
new
exe "next Xfile " . longfilename