Skip to content
Myr

[vim] Preserve current directory in case someone changes it (#2096)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Preserve current directory in case current directory is changed by others after the call of s:open

authored by Yanlin Sun · committed by GitHub · parent 8e027c4 · Browse files · 1 file+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>

Diff stats

1 file+6 added−3 removed

  • other:+6 added−3 removed

1 file+6 added−3 removed

modified:plugin/fzf.vim+6 added-3 removed
234 unmodified lines
235 augroup END236 endif237 try238 let empty = empty(s:fzf_expand('%')) && line('$') == 1 && empty(getline(1)) && !&modified239 let autochdir = &autochdir240 set noautochdir239 " Preserve the current working directory in case it's changed during240 " the execution (e.g. `set autochdir` or `autocmd BufEnter * lcd ...`)241 let cwd = exists('w:fzf_pushd') ? w:fzf_pushd.dir : expand('%:p:h')242 for item in a:lines243 if item[0] != '~' && item !~ (s:is_win ? '^[A-Z]:\' : '^/')244 let item = join([cwd, item], (s:is_win ? '\' : '/'))245 endif246 if empty247 execute 'e' s:escape(item)248 let empty = 0249 else
5 unmodified lines
255 endif256 endfor257 catch /^Vim:Interrupt$/258 finally255 let &autochdir = autochdir259 silent! autocmd! fzf_swap260 endtry261endfunction262
693 unmodified lines