Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashing when chdir function doesn't exist #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autoload/gopher/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ fun! gopher#go#module() abort
let l:wd = getcwd()

try
call chdir(expand('%:h'))
call gopher#system#cd(expand('%:h'))
let [l:out, l:err] = gopher#system#run(['go', 'list', '-m', '-f',
\ "{{.Path}}\x01{{.Dir}}"])
if l:err
return [-1, -1]
endif
return split(l:out, "\x01")
finally
call chdir(l:wd)
call gopher#system#cd(l:wd)
endtry
endfun

Expand Down
9 changes: 9 additions & 0 deletions autoload/gopher/system.vim
Original file line number Diff line number Diff line change
Expand Up @@ -499,5 +499,14 @@ fun! gopher#system#closest(name) abort
endwhile
endfun

" Change the current directory to path.
fun! gopher#system#cd(path) abort
if exists('*chdir')
call chdir(a:path)
else
silent execute 'lcd' fnameescape(a:path)
endif
endfun


call s:init() " At end so entire file is parsed.