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

Buffer stderr and stdout before triggering callbacks #44

Closed
wants to merge 2 commits into from

Conversation

kjughx
Copy link

@kjughx kjughx commented Oct 29, 2024

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 vim.fn.jobstart will wait until they finish writing to those descriptors, reducing the calls to on_stdout and on_stderr to at most one.

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.
@ej-shafran
Copy link
Owner

What about, say, a command like echo 'hello world'; sleep 10; echo 'goodbye'? Ideally, this command would write out "hello world", then wait ten seconds, then write out "goodbye". With stdout_buffered, will this still work as expected?

ej-shafran added a commit that referenced this pull request Oct 30, 2024
@ej-shafran
Copy link
Owner

ej-shafran commented Oct 30, 2024

As you can see, I've added a test to cover the aforementioned scenario. The test is failing on this branch, but succeeding in main. Since this pull request breaks the expected behavior, I'm closing it.

However, please note that the :Compile and :Recompile commands can be run synchronously (i.e. the output is only put in the compilation buffer once the entire command has finished):

With a bang (:Compile!), the compilation buffer will only be updated
once the command finishes (i.e. the compilation command will be run
synchronously).

(From the docs)

@ej-shafran ej-shafran closed this Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants