Weyaaron / nvim-training

A plugin to practice neovim movements, currently in "open beta"
GNU General Public License v3.0
36 stars 3 forks source link

[Bug]: When the plugin tries to proceed to the next task, it encounters an error that there are unsaved changes in the current buffer. #24

Closed The-Sirius-Black closed 1 month ago

The-Sirius-Black commented 1 month ago

Describe the bug

When the plugin goes to the next task, it encounters an error due to unsaved changes in the current buffer. After pressing Enter or saving, it sometimes breaks and skips tasks while still counting failures, while at other times it functions correctly.

https://github.com/user-attachments/assets/144acd9e-1d97-469e-b404-d794da05e9a7

How to reproduce the behavior

I got this behavior when i started this plugin for first time with :Training 

Expected behavior.

Iterating through tasks witouth error message

Logs and Stack traces

Error executing vim.schedule lua callback: vim/_editor.lua:431: nvim_exec2(): Vim(edit):E37: No write since last change (add ! to override)                                                       stack traceback:                                                                                                                                                                                          [C]: in function 'nvim_exec2'                                                                                                                                                                     vim/_editor.lua:431: in function 'cmd'                                                                                                                                                            C:/Users/user/nvim-training/plugin/nvim-training.lua:95: in function 'fn'                                                                                                                          vim/_editor.lua:351: in function <vim/_editor.lua:350>

Screenshots

No response

Additional Context

Adding code below before vim.cmd("sil e training.txt") at plugin/nvim-training.lua 94 ln seems to fix issue.

if vim.bo.modified then
     vim.cmd("write!")
end

Environment

Windows, mac same issues nvim 0.10, powershell and iterm
Weyaaron commented 1 month ago

Thanks for reporting it with such detail. I can reproduce this, a fix will be released soon.

Weyaaron commented 1 month ago

25 Should have fixed this, let me know if there are any remaining issues.