Support Windows UNC path#245
Conversation
lambdalisue
left a comment
There was a problem hiding this comment.
Thanks for your contribution. But I'm sorry, I don't think supporting the Windows UNC path has worth introducing this much complexity to the existing code. Please consider making a new fern scheme plugin to support it (like fern:///unc://{host}/{path}).
| @@ -12,26 +12,28 @@ function! fern#fri#new(partial) abort | |||
| endfunction | |||
|
|
|||
| function! fern#fri#parse(expr) abort | |||
There was a problem hiding this comment.
I don't get why you need to apply changes to fern#fri#parse().
Supporting the Windows UNC path should not touch FRI itself or let me know the reason.
There was a problem hiding this comment.
Fix authority and path parsing.
Changed result of 'foo://bar/' below.
""" Old
echo fern#fri#parse('foo://bar/qux')
" => {'query': {}, 'authority': 'bar', 'fragment': '', 'scheme': 'foo', 'path': 'qux'}
echo fern#fri#parse('foo://bar/')
" => {'query': {}, 'authority': '', 'fragment': '', 'scheme': 'foo', 'path': 'bar'}
echo fern#fri#parse('foo://bar')
" => {'query': {}, 'authority': '', 'fragment': '', 'scheme': 'foo', 'path': 'bar'}
""" New
echo fern#fri#parse('foo://bar/qux')
" => {'query': {}, 'authority': 'bar', 'fragment': '', 'scheme': 'foo', 'path': 'qux'}
echo fern#fri#parse('foo://bar/')
" => {'query': {}, 'authority': 'bar', 'fragment': '', 'scheme': 'foo', 'path': ''}
echo fern#fri#parse('foo://bar')
" => {'query': {}, 'authority': '', 'fragment': '', 'scheme': 'foo', 'path': 'bar'}
There was a problem hiding this comment.
I see. So this is kinda bug fix, right? It would be nice if you separate it to a different PR.
| endfunction | ||
|
|
||
| function! fern#internal#filepath#is_unc_compat() abort | ||
| return g:fern#internal#filepath#is_windows |
There was a problem hiding this comment.
If Neovim 0.4.4 does not support the UNC path, we should check it here, right?
Additionally, it would be nice to make an issue on the Neovim side and put the issue URL here to explain why we need to exclude Neovim.
| endfunction | ||
|
|
||
| function! fern#internal#filepath#is_uncpath(path) abort | ||
| return g:fern#internal#filepath#is_windows && s:is_uncpath(a:path) |
There was a problem hiding this comment.
We should NOT check g:fern#internal#filepath#is_windows here while the function purpose is to check if the path is a UNC path or not.
|
|
||
| function! s:is_absolute_windows(path) abort | ||
| return a:path ==# '' || a:path[:2] =~# '^\w:\\$' | ||
| return a:path ==# '' || a:path[:2] =~# '^\w:\\$' || s:is_uncpath(a:path) |
There was a problem hiding this comment.
I guess it's not correct. It just checks if the path is a UNC path and it does not check if the path is an absolute UNC path, right?
| let path = fern#internal#filepath#to_slash(a:node._path) | ||
| let parent = fern#internal#path#dirname(path) | ||
| let parent = fern#internal#filepath#from_slash(parent) | ||
| if s:is_windows && fern#internal#filepath#is_uncpath(a:node._path) |
There was a problem hiding this comment.
I think we should use fern#internal#filepath#is_uncpath_compat()
| call fern#logger#debug('file:get_root:filepath', path) | ||
| if s:is_windows && path ==# '' | ||
| return s:windows_drive_root | ||
| elseif s:is_windows && fern#internal#filepath#is_uncpath(path) |
There was a problem hiding this comment.
I think we should use fern#internal#filepath#is_uncpath_compat()
| @@ -1,17 +1,18 @@ | |||
| function! fern#internal#command#do#command(mods, fargs) abort | |||
| function! fern#internal#command#do#command(mods, qargs) abort | |||
There was a problem hiding this comment.
The function interface must not be changed while the function itself is OK.
| \ -complete=customlist,fern#internal#command#fern#complete | ||
| \ Fern | ||
| \ call fern#internal#command#fern#command(<q-mods>, [<f-args>]) | ||
| \ call fern#internal#command#fern#command(<q-mods>, <q-args>) |
There was a problem hiding this comment.
I'm planning to change the entire behavior of args handling because of #246 thus please don't touch these in this PR.
Unfortunately neovim does not support UNC path.
in neovim 0.4.4
getftype('\\localhost\C$\')=> 'dir' 👌glob('\\localhost\C$\*')=> [] 😢getcompletion('\\localhost\C$\', 'file')=> [] 😢