diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index a80e949..47413b6 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -637,14 +637,17 @@ endfunction " fzf#run restores the working directory while fzf runs and only re-applies " 'dir' for the sink, so a relative entry has to be resolved here function! s:in_dir(dir, path) abort - " filereadable does not expand a leading tilde, which :History reports - if a:path =~# '^\~' - return fnamemodify(a:path, ':p') - endif if empty(a:dir) || a:path =~# '^/' || a:path =~# '^\a:[\\/]' return a:path endif - return fnamemodify(expand(escape(a:dir, '[]*?{}')), ':p').a:path + let path = fnamemodify(expand(escape(a:dir, '[]*?{}')), ':p').a:path + " :History reports a path under the home directory as '~/...', which + " filereadable does not expand. Other commands can emit a relative path + " under a directory named '~', so prefer that reading when it exists + if a:path =~# '^\~' && !filereadable(path) + return fnamemodify(a:path, ':p') + endif + return path endfunction " Shows the entry without closing fzf. The callback can fire while the fzf