Skip to content

Conversation

@jimmyl0l3c
Copy link

@jimmyl0l3c jimmyl0l3c commented Dec 12, 2025

Fixes #27, fixes #19 , fixes #23.

How to reproduce the bug I am fixing:

  • Call ShowkeysToggle
  • Press a random character, for example h
  • While the showkeys window is visible, press some operation that waits for motion, like d, this takes you to operator-pending mode
  • When timer of the pending operation (d in this example) fires the utils.clear_and_close callback, the error occurs

The cause: the timer of the character pressed before entering operator-pending mode (h in my example) gets scheduled before it gets cancelled by timer:stop when handling the pending operation (d in my example). Because of this, the callback gets executed twice and during the second execution, the state.win is nil, causing the error.

My solution is to save timer_id, so we can check whether the current callback is the last scheduled one.

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.

nvim_win_set_config Getting unexpected errors !!! Error in vim.schedule lua callback

1 participant