Skip to content

Commit

Permalink
Fix root path issue in Windows
Browse files Browse the repository at this point in the history
"C:" is not a root directory and a CWD is used instead so append "\" to avoid this behavior.
Close #69
  • Loading branch information
mattn committed Feb 6, 2020
1 parent d56a43d commit fdc0bbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion autoload/fern/scheme/file/fri.vim
Expand Up @@ -5,14 +5,21 @@ function! fern#scheme#file#fri#to_fri(path) abort
let path = s:Path.abspath(a:path)
let path = s:Path.remove_last_separator(path)
let path = s:Path.to_slash(path)
return printf('file:///%s', join(split(path, '/'), '/'))
let path = printf('file:///%s', join(split(path, '/'), '/'))
if s:is_windows && a:path =~# '^\w:/$'
let path .= '/'
endif
return path
endfunction

function! fern#scheme#file#fri#from_fri(fri) abort
let path = s:is_windows ? a:fri.path : '/' . a:fri.path
let path = s:Path.from_slash(path)
let path = s:Path.abspath(path)
let path = s:Path.remove_last_separator(path)
if s:is_windows && path =~# '^\w:$'
let path .= '\'
endif
let path = empty(path) ? '/' : path
return path
endfunction
3 changes: 3 additions & 0 deletions autoload/fern/scheme/file/provider.vim
Expand Up @@ -49,6 +49,9 @@ function! s:node(path) abort
let path = s:Path.abspath(a:path)
let path = s:Path.remove_last_separator(path)
let path = simplify(path)
if s:is_windows && path =~# '^\w:$'
let path .= '\'
endif
let path = empty(path) ? '/' : path
if empty(getftype(path))
throw printf('no such file or directory exists: %s', path)
Expand Down

0 comments on commit fdc0bbc

Please sign in to comment.