Skip to content

Commit 1c5cc5f

Browse files
committed
Add no-op to "flush" plugin -> neovim msg buffer
Sometimes, during a repl-log or dismiss-repl-log call, the plugin reports that it has written the vim_get_buffers (request) message to the plugin's output stream. However, neovim (compiled in debug mode doesn't report receiving it. This is a workaround, not a true fix. Immediately following the repl-log requests (neovim -> plugin), neovim also sends a no-op request. The resulting response (to the no-op), from the plugin appears to "flush" the plugin -> neovim message "buffer". Also worth mentioning, we are not able to reproduce this issue during debug, when using a TCP socket connection. It only occurs when using STDIO. Also tried using stdbuf to reduce buffering of the streams, adding a .flush call after every message, to no avail.
1 parent f06c7a8 commit 1c5cc5f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

plugin/socketrepl.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function! StartIfNotRunning()
66
if g:is_running == 0
77
echo 'Starting SocketREPL client...'
88
let jar_file_path = s:p_dir . '/../' . 'socket-repl-plugin-0.1.0-SNAPSHOT-standalone.jar'
9-
let g:channel = rpcstart('java', ['-jar', jar_file_path])
9+
let g:channel = rpcstart('stdbuf', ['--input=0', '--output=0', 'java', '-jar', jar_file_path])
1010
let g:is_running = 1
1111
endif
1212
endfunction
@@ -42,13 +42,17 @@ command! EvalCode call EvalCode()
4242
function! ReplLog(buffer_cmd)
4343
call StartIfNotRunning()
4444
let res = rpcrequest(g:channel, 'show-log', a:buffer_cmd)
45+
" Response to no-op will 'flush' plugin -> neovim message 'buffer'
46+
call rpcrequest(g:channel, 'no-op', '')
4547
return res
4648
endfunction
4749
command! ReplLog call ReplLog(':botright new')
4850

4951
function! DismissReplLog()
5052
call StartIfNotRunning()
5153
let res = rpcrequest(g:channel, 'dismiss-log', [])
54+
" Response to no-op will 'flush' plugin -> neovim message 'buffer'
55+
call rpcrequest(g:channel, 'no-op', '')
5256
return res
5357
endfunction
5458
command! DismissReplLog call DismissReplLog()
310 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)