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

fix: YaziRenamedOrMoved events could not be published in practice #499

Merged
merged 2 commits into from
Oct 5, 2024

Conversation

mikavilpas
Copy link
Owner

Issue

When a file was renamed/moved, a YaziRenamedOrMoved event was supposed to be published. However, the event was not actually published in practice due to E5560: nvim_exec_autocmds must not be called in a lua loop callback.

Solution

The solution was to schedule the event publishing in a vim.schedule block. This way, the event publishing is deferred to the next event loop iteration, which avoids the error.

For some reason, this error is not visible in unit tests, so I added an integration test to make sure it doesn't break again.

Issue
=====

When a file was renamed/moved, a YaziRenamedOrMoved event was supposed to be
published. However, the event was not actually published in practice due
to `E5560: nvim_exec_autocmds must not be called in a lua loop
callback`.

Solution
========

The solution was to schedule the event publishing in a `vim.schedule` block.
This way, the event publishing is deferred to the next event loop iteration,
which avoids the error.

For some reason, this error is not visible in unit tests, so I added an
integration test to make sure it doesn't break again.
@mikavilpas mikavilpas enabled auto-merge (squash) October 5, 2024 07:28
@mikavilpas mikavilpas merged commit e379516 into main Oct 5, 2024
14 checks passed
@mikavilpas mikavilpas deleted the fix-rename-event-publishing branch October 5, 2024 07:30
This was referenced Jan 23, 2025
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.

1 participant