[vim/vim] netrw: Fix handling of very long filename on longlist style (PR #12150)

45 views
Skip to first unread message

K.Takata

unread,
Mar 13, 2023, 7:11:12 AM3/13/23
to vim/vim, Subscribed

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, 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:50:36 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
こんにちは                        6 Mon Mar 13 19:30:41 2023

Now, two space characters are always inserted between the name and the size, and the last line is also aligned.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/12150

Commit Summary

  • 93deb42 netrw: Fix handling of very long filename on longlist style

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150@github.com>

Christian Brabandt

unread,
Mar 13, 2023, 7:24:02 AM3/13/23
to vim/vim, Subscribed

possibly fixes #10315


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1465966126@github.com>

K.Takata

unread,
Mar 13, 2023, 8:01:56 AM3/13/23
to vim/vim, Push

@k-takata pushed 2 commits.

  • 774c18d netrw: Fix handling of very long filename on longlist style
  • 0a9d9af Align filesize


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/push/12921371935@github.com>

codecov[bot]

unread,
Mar 13, 2023, 8:02:26 AM3/13/23
to vim/vim, Subscribed

Codecov Report

Merging #12150 (93deb42) into master (e764d1b) will decrease coverage by 81.67%.
The diff coverage is n/a.

Current head 93deb42 differs from pull request most recent head 0a9d9af. Consider uploading reports for the commit 0a9d9af to get more accurate results

@@             Coverage Diff             @@
##           master   #12150       +/-   ##
===========================================
- Coverage   81.95%    0.29%   -81.67%     
===========================================
  Files         164      154       -10     
  Lines      194086   179274    -14812     
  Branches    43828    40967     -2861     
===========================================
- Hits       159069      522   -158547     
- Misses      22183   178695   +156512     
+ Partials    12834       57    -12777     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 0.29% <ø> (ø)
linux 0.29% <ø> (-82.10%) ⬇️
mingw-x64-HUGE ?
mingw-x86-HUGE ?
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

see 158 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1466015180@github.com>

K.Takata

unread,
Mar 13, 2023, 8:18:54 AM3/13/23
to vim/vim, Subscribed

I've updated the patch to align the filesize.

E.g.:

" ============================================================================
" 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.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1466041099@github.com>

K.Takata

unread,
Mar 14, 2023, 2:29:47 AM3/14/23
to vim/vim, Push

@k-takata pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/push/12932367869@github.com>

K.Takata

unread,
Mar 15, 2023, 1:44:47 AM3/15/23
to vim/vim, Push

@k-takata pushed 2 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/push/12946761966@github.com>

K.Takata

unread,
Mar 15, 2023, 1:50:15 AM3/15/23
to vim/vim, Subscribed

Also fixed an 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'.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1469380515@github.com>

K.Takata

unread,
Mar 15, 2023, 2:17:23 AM3/15/23
to vim/vim, Subscribed

Cc: @cecamp


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1469405550@github.com>

cecamp

unread,
Mar 15, 2023, 11:01:55 PM3/15/23
to vim/vim, Subscribed

Unfortunately my email is seriously broken at the moment, and I'm gone until next week. My website is down, too, btw. I'll look into this when I can.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1471211650@github.com>

K.Takata

unread,
Apr 23, 2023, 10:01:23 PM4/23/23
to vim/vim, Push

@k-takata pushed 1 commit.

  • 1b55c94 Rewrite the patch for Netrw v172

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/push/13399267878@github.com>

K.Takata

unread,
Apr 23, 2023, 10:05:38 PM4/23/23
to vim/vim, Subscribed

@cecamp

I've tried Netrw v172 and it still has the above alignment and sort issues.
I've updated my patch for v172. Could you check it again?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1519278735@github.com>

K.Takata

unread,
Jun 18, 2023, 1:25:30 AM6/18/23
to vim/vim, Subscribed

Cf. https://groups.google.com/g/vim_dev/c/QCMDKKQrakQ


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1595960902@github.com>

K.Takata

unread,
Jun 18, 2023, 1:49:59 AM6/18/23
to vim/vim, Subscribed

This also fixes #4899.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1595971734@github.com>

Yegappan Lakshmanan

unread,
Aug 13, 2023, 4:42:02 PM8/13/23
to vim/vim, Subscribed

Any updates on this?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1676458029@github.com>

K.Takata

unread,
Nov 22, 2023, 3:38:03 AM11/22/23
to vim/vim, Subscribed

@chrisbra
I've confirmed that this has been already merged in Netrw v174b. However, it has not been included in this repository yet.
Can we merge this PR in advance?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1822323915@github.com>

Christian Brabandt

unread,
Nov 22, 2023, 3:45:10 AM11/22/23
to vim/vim, Subscribed

okay sure. Thanks!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1822333803@github.com>

Christian Brabandt

unread,
Nov 22, 2023, 3:47:42 AM11/22/23
to vim/vim, Subscribed

I was preparing to merge it. Can you please add a simple header line like this one:
https://github.com/vim/vim/blob/4e5c3cf07bfc904b2a558f1d08a7f8a9732ed7db/runtime/autoload/netrw.vim#L5-L6


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1822337321@github.com>

K.Takata

unread,
Nov 22, 2023, 3:59:00 AM11/22/23
to vim/vim, Push

@k-takata pushed 1 commit.

  • 79789cc netrw: Fix handling of very long filename on longlist style


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/push/15921788279@github.com>

K.Takata

unread,
Nov 22, 2023, 3:59:17 AM11/22/23
to vim/vim, Push

@k-takata pushed 1 commit.

  • ac06f5a netrw: Fix handling of very long filename on longlist style


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/push/15921791740@github.com>

K.Takata

unread,
Nov 22, 2023, 4:00:06 AM11/22/23
to vim/vim, Subscribed

@chrisbra Updated. Could you check it?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1822355519@github.com>

K.Takata

unread,
Nov 22, 2023, 4:12:22 AM11/22/23
to vim/vim, Subscribed

Updated the commit log.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1822373916@github.com>

Christian Brabandt

unread,
Nov 22, 2023, 4:20:47 AM11/22/23
to vim/vim, Subscribed

Merged #12150 into master.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/issue_event/11033862516@github.com>

Christian Brabandt

unread,
Nov 22, 2023, 4:20:52 AM11/22/23
to vim/vim, Subscribed

thanks!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12150/c1822388268@github.com>

Reply all
Reply to author
Forward
0 new messages