From fdc0bbcac4735ace3e1d06d93e938600188312fe Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 6 Feb 2020 09:19:47 +0900 Subject: [PATCH] Fix root path issue in Windows "C:" is not a root directory and a CWD is used instead so append "\" to avoid this behavior. Close #69 --- autoload/fern/scheme/file/fri.vim | 9 ++++++++- autoload/fern/scheme/file/provider.vim | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/fern/scheme/file/fri.vim b/autoload/fern/scheme/file/fri.vim index f2416928..42108cfe 100644 --- a/autoload/fern/scheme/file/fri.vim +++ b/autoload/fern/scheme/file/fri.vim @@ -5,7 +5,11 @@ 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 @@ -13,6 +17,9 @@ function! fern#scheme#file#fri#from_fri(fri) abort 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 diff --git a/autoload/fern/scheme/file/provider.vim b/autoload/fern/scheme/file/provider.vim index 40ff81ec..2af4fed6 100644 --- a/autoload/fern/scheme/file/provider.vim +++ b/autoload/fern/scheme/file/provider.vim @@ -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)