Skip to content

Commit

Permalink
Buffer stderr and stdout before triggering callbacks
Browse files Browse the repository at this point in the history
Currently, whenever the compile_command outputs data on stdout or stderr
the corresponding on_stdout or on_stderr is called. This results in
multiple (at least 5 for even one compilation error) calls to those
functions which in turn do some work parsing errors. Adding
stdout_buffered and stderr_buffered to jobstart will wait until they
finish writing to those descriptors, reducing the calls to on_stdout and
on_stderr to at most one.
  • Loading branch information
kjughx committed Oct 29, 2024
1 parent 2bf8381 commit c0f255a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/compile-mode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ local runjob = a.wrap(function(cmd, bufnr, param, callback)
log.debug("starting job...")
local job_id = vim.fn.jobstart(cmd, {
cwd = vim.g.compilation_directory,
stdout_buffered = true,
on_stdout = on_either,
stderr_buffered = true,
on_stderr = on_either,
on_exit = function(id, code)
callback(count, code, id)
Expand Down

0 comments on commit c0f255a

Please sign in to comment.