Skip to content

Commit 157b928

Browse files
committed
switch working directory to buffer's folder
Fixes #36. Also, fixes a bug in Vim8 where we called the wrong method on chdir.
1 parent aad1045 commit 157b928

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

after/ftplugin/markdown/composer.vim

+5-3
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,14 @@ endfunction
134134

135135
function! s:chdir()
136136
if exists('s:job')
137+
let l:cwd = expand('%:p:h')
138+
137139
if has('nvim')
138-
call rpcnotify(s:job, 'chdir', getcwd())
140+
call rpcnotify(s:job, 'chdir', l:cwd)
139141
else
140142
call ch_sendexpr(s:job, {
141-
\ 'method': 'open_browser',
142-
\ 'params': [getcwd()],
143+
\ 'method': 'chdir',
144+
\ 'params': [l:cwd],
143145
\ })
144146
endif
145147
endif

src/main.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ fn read_rpc<R>(reader: R, browser: &Option<String>, handle: &mut Listening) wher
134134
open_browser(&handle.http_addr().unwrap(), &browser);
135135
},
136136
"chdir" => {
137-
handle.change_working_directory(rpc.params[0].clone());
138-
},
137+
let cwd = &rpc.params[0];
138+
info!("changing working directory: {}", cwd);
139+
handle.change_working_directory(cwd);
140+
}
139141
method => panic!("Received unknown command: {}", method),
140142
}
141143
}

0 commit comments

Comments
 (0)