sbdchd / neoformat

:sparkles: A (Neo)vim plugin for formatting code.
BSD 2-Clause "Simplified" License
1.98k stars 189 forks source link

truncating files #457

Open mvolkmann opened 1 year ago

mvolkmann commented 1 year ago

When I have this plugin installed and I save changes to a large file (10000 lines or more), sometimes hundreds of lines at the end of the file get deleted. So far I have only noticed this in very large Markdown files. I suspect what is happening is that when I enter ":w" to write the file, neoformat begins formatting the file and before it can finish, the part it has formatted so far gets written out. I can reproduce the issue by adding a markdown table anywhere in the file and entering ":w". For example, something like this:

| foo | bar |
|-|-|
| test | this |

Neoformat adjusts all the cell widths in the Markdown table to line up nicely which I love.

mvolkmann commented 1 year ago

It seems that if I type ":w" and wait two seconds before pressing the return key, this does not happen. So I suspect it is a timing issue related to giving the formatting time to finish before writing out the file.