mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
62dc1f2663
runtime(netrw): Fix handling of very long filename on longlist style (vim/vim#12150)
If there is a file with a very long filename (longer than
g:netrw_maxfilenamelen), and if g:netrw_liststyle is set to 1, no space
is inserted between the filename and the filesize and the file cannot be
opened because of this.
E.g.:
```
$ echo hello > 12345678901234567890123456789012 # 32 bytes: OK
$ echo hello > 123456789012345678901234567890123 # 33 bytes: not OK
$ echo hello > 1234567890123456789012345678901234 # 34 bytes: not OK
$ echo hello > こんにちは # multibyte filename
$ LC_ALL=C.UTF-8 vim . --clean --cmd "set loadplugins" --cmd "let g:netrw_liststyle=1"
```
Then, it will be shown like this:
```
" ============================================================================
" Netrw Directory Listing (netrw v171)
" /cygdrive/c/work/netrw-test
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:special
" ==============================================================================
../ 0 Mon Mar 13 19:25:16 2023
./ 0 Mon Mar 13 19:44:58 2023
12345678901234567890123456789012 6 Mon Mar 13 19:29:43 2023
12345678901234567890123456789012346 Mon Mar 13 19:32:40 2023
1234567890123456789012345678901236 Mon Mar 13 19:29:49 2023
こんにちは 6 Mon Mar 13 19:30:41 2023
```
If the length of the filename is 32 bytes, there is a space between the
filename and the filesize. However, when it is longer than 32 bytes, no
space is shown.
Also, you may find that the filesize of the multibyte named file is not
aligned.
After this patch is applied, the filelist will be shown like this:
```
" ============================================================================
" Netrw Directory Listing (netrw v171)
" /cygdrive/c/work/netrw-test
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:special
" ==============================================================================
../ 0 Mon Mar 13 20:49:22 2023
./ 0 Mon Mar 13 21:12:14 2023
1234567890123456789012345678901 10000 Mon Mar 13 20:57:55 2023
12345678901234567890123456789012 6 Mon Mar 13 19:29:43 2023
123456789012345678901234567890123 6 Mon Mar 13 19:29:49 2023
1234567890123456789012345678901234 6 Mon Mar 13 19:32:40 2023
1234567890123456789012345678901234567 10000 Mon Mar 13 21:03:23 2023
1234567890123456789012345678901234567890 10000 Mon Mar 13 21:03:36 2023
123456789012345678901234567890123456789012 10000 Mon Mar 13 21:03:59 2023
1234567890123456789012345678901234567890123 10000 Mon Mar 13 21:03:45 2023
1234567890123456789012345678901234567890123456 5 Mon Mar 13 21:08:15 2023
12345678901234567890123456789012345678901234567 10 Mon Mar 13 21:05:21 2023
こんにちは 6 Mon Mar 13 19:30:41 2023
```
Now we have 32 + 2 + 15 = 49 characters for filename and filesize.
It tries to align the filesize as much as possible.
The last line that has multibyte filename is also aligned.
Also fixed the issue that the file list is not shown correctly when
g:netrw_sort_by is set to 'size' and g:netrw_sizestyle is set to 'h' or
'H'.
|
||
---|---|---|
.. | ||
autoload | ||
colors | ||
compiler | ||
doc | ||
ftplugin | ||
indent | ||
keymap | ||
lua | ||
macros | ||
pack/dist/opt | ||
plugin | ||
queries | ||
spell | ||
syntax | ||
tools | ||
tutor | ||
CMakeLists.txt | ||
delmenu.vim | ||
filetype.lua | ||
ftoff.vim | ||
ftplugin.vim | ||
ftplugof.vim | ||
indent.vim | ||
indoff.vim | ||
macmap.vim | ||
makemenu.vim | ||
menu.vim | ||
mswin.vim | ||
neovim.ico | ||
nvim.appdata.xml | ||
nvim.desktop | ||
nvim.png | ||
optwin.vim | ||
synmenu.vim |