New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Netrw fails to open file with long filename #10055
Comments
See :help g:netrw_maxfilenamelen and set it to a larger number. |
I think there is some room for improvements. If I read the code correctly, when pressing Enter, netrw is trying to determine the filename by using: vim/runtime/autoload/netrw.vim Line 4470 in a6c18d3
If I read the regexp correctly, this expects at least 2 spaces after the filename. So we would need to fix this in vim/runtime/autoload/netrw.vim Line 11092 in a6c18d3
By adding 2. And finally to make it work, I think this line here: vim/runtime/autoload/netrw.vim Line 11020 in a6c18d3
should be 1, so that it adds additional spaces by default. (if not, it won't automatically adjust Altogether this patch seems to fix it: diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index 7d1a35c1a..395ff0243 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -11017,7 +11017,7 @@ fun! s:LocalListing()
" call Decho("before while: dirnamelen<".dirnamelen.">",'~'.expand("<slnum>"))
" call Decho("before while: filelist =".string(filelist),'~'.expand("<slnum>"))
- if get(g:, 'netrw_dynamic_maxfilenamelen', 0)
+ if get(g:, 'netrw_dynamic_maxfilenamelen', 1)
let filelistcopy = map(deepcopy(filelist),'fnamemodify(v:val, ":t")')
let g:netrw_maxfilenamelen = max(map(filelistcopy,'len(v:val)')) + 1
" call Decho("dynamic_maxfilenamelen: filenames =".string(filelistcopy),'~'.expand("<slnum>"))
@@ -11089,7 +11089,7 @@ fun! s:LocalListing()
if g:netrw_sizestyle =~# "[hH]"
let sz= s:NetrwHumanReadable(sz)
endif
- let longfile= printf("%-".(g:netrw_maxfilenamelen+1)."s",pfile)
+ let longfile= printf("%-".(g:netrw_maxfilenamelen+2)."s",pfile)
let pfile = longfile.sz." ".strftime(g:netrw_timefmt,getftime(filename))
" call Decho("longlist support: sz=".sz." fsz=".fsz,'~'.expand("<slnum>"))
endif |
And the next complaint will be that for 33+ character filenames that the long listing display is uneven. I suppose that that's better than picking up an incorrectly named file, so I'll include it. |
Steps to reproduce
Add
let g:netrw_liststyle = 1
to.vimrc
Create a directory with several files like in the following screenshot
123456789012345678901234567890
and1234567890123456789012345678901
open correctly12345678901234567890123456789012
does not open correctly. Vim opens the12345678901234567890123456789012 29 Thu Mar 31 13:17:54 2022
file instead. Same problem with123456789012345678901234567890123
.Expected behaviour
File
12345678901234567890123456789012
should open correctly.Version of Vim
8.2.4113
Environment
Operating System: macOS 12.3 (I'm running the macOS default version of Vim)
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 12 2022 04:26:50)
macOS version - x86_64
Included patches: 1-4113
Compiled by root@apple.com
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: