Skip to content

Commit b947d51

Browse files
authored
SideSearch(): if cmd is called with a path at the end, convert it to absolute path (#17)
* SideSearch(): if cmd is called with a path at the end, convert it to absolute path This fixes use case, when for example user specifies a relative path as the last argument to `:SideSearch` and then navigates from one file to another while his Vim config changes current Vim dir on every file/buffer opening/selection, for example with this config: ``` set autochdir autocmd BufEnter * lcd %:p:h ``` * Update side-search.vim
1 parent ace1038 commit b947d51

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugin/side-search.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@ function! SideSearch(term, ...) abort
203203
call s:append_guide()
204204

205205
let b:escaped = shellescape(a:term)
206-
let b:cmd = g:side_search_prg . ' ' . b:escaped . ' ' . join(a:000, ' ')
206+
let b:cmd = g:side_search_prg . ' ' . b:escaped
207207

208208
" Guess the directory if value path is not provided as last argument
209209
if len(a:000) == 0 || isdirectory(a:000[-1]) == 0
210-
" guess the directory
211210
let l:cwd = s:guessProjectRoot()
212-
let b:cmd = b:cmd . l:cwd
211+
let b:cmd = b:cmd . ' ' . join(a:000, ' ') . ' ' . fnamemodify(l:cwd, ':p')
212+
else
213+
let b:cmd = b:cmd . ' ' . join(a:000[0:-2], ' ') . ' ' . fnamemodify(a:000[-1], ':p')
213214
endif
214215

215216
" echom 'a:term => ' . a:term

0 commit comments

Comments
 (0)