@@ -47,11 +47,15 @@ def __init__(self, nvim):
47
47
48
48
# Handle DirChanged. #296
49
49
nvim .command (
50
- 'autocmd DirChanged * call rpcrequest ({}, "python_chdir", v:event)'
50
+ 'au DirChanged * call rpcnotify ({}, "python_chdir", v:event.cwd )'
51
51
.format (nvim .channel_id ), async_ = True )
52
52
# XXX: Avoid race condition.
53
53
# https://github.com/neovim/python-client/pull/296#issuecomment-358970531
54
- os .chdir (nvim .eval ('getcwd()' , async_ = False ))
54
+ # TODO(bfredl): when host initialization has been refactored,
55
+ # to make __init__ safe again, the following should work:
56
+ # os.chdir(nvim.eval('getcwd()', async_=False))
57
+ nvim .command ('call rpcnotify({}, "python_chdir", getcwd())'
58
+ .format (nvim .channel_id ), async_ = True )
55
59
56
60
def setup (self , nvim ):
57
61
"""Setup import hooks and global streams.
@@ -161,10 +165,10 @@ def python_eval(self, expr):
161
165
"""Handle the `pyeval` vim function."""
162
166
return eval (expr , self .module .__dict__ )
163
167
164
- @rpc_export ('python_chdir' , sync = True )
165
- def python_chdir (self , args ):
168
+ @rpc_export ('python_chdir' , sync = False )
169
+ def python_chdir (self , cwd ):
166
170
"""Handle working directory changes."""
167
- os .chdir (args [ ' cwd' ] )
171
+ os .chdir (cwd )
168
172
169
173
def _set_current_range (self , start , stop ):
170
174
current = self .legacy_vim .current
0 commit comments