Skip to content

Conversation

@e-cal
Copy link
Contributor

@e-cal e-cal commented Jan 23, 2026

Fixes #44, previous fix seems not to always work and the issue persists.

Replaces vim.system with vim.fn.jobstart. jobstart streams data as it comes in while vim.system seems to buffer more aggressively occasionally missing events.

Copilot AI review requested due to automatic review settings January 23, 2026 03:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@NickvanDyke
Copy link
Owner

Darn, I was excited to migrate to the newer vim.system haha. I guess I didn't test extensively enough.

occasionally missing events

Missing entirely? Or just delayed? The former makes me think maybe I just introduced a bug while migrating. vim.fn.jobstart passes data[], whereas vim.system is data. So I may have misunderstood how to adjust for that.

@e-cal
Copy link
Contributor Author

e-cal commented Jan 23, 2026

Missing entirely such that the buffer reload autocommand doesn't trigger, since while its processing the batch it isn't listening. It's dependent on how fast opencode is sending the events, but since file.edited is much less common than the message updated ones it gets buried and much more likely to be one of the missed events.

From the docs I think Job_control is also simply the API designed for this use case more so than vim.system

Job_control

Job control is a way to perform multitasking in Nvim, so scripts can spawn and control multiple processes without blocking the current Nvim instance.
...
Job stdio streams form a channel which can send and receive raw bytes or msgpack-rpc messages.

vim.system on the other hand uses uv.spawn under the hood:

Initializes the process handle and starts the process. If the process is successfully spawned, this function will return the handle and pid of the child process.

While it's meant to replace job control eventually, it seems to me that right now it is polling the stdout/stderr of the subprocess at set intervals rather than streaming in the raw data.

So far I can't seem to reliably get around this with vim.system while vim.fn.jobstart works consistently and reliably.

@NickvanDyke NickvanDyke merged commit 7ae1f9a into NickvanDyke:main Jan 23, 2026
2 checks passed
@NickvanDyke
Copy link
Owner

Thanks for the details! And the clean fix. I guess the code is at least a bit cleaner now than it was pre-vim.system, so still a win 🙂

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.

bug: missing file.edited events from Opencode

2 participants