100% CPU usage when appending a non-space character to a comment that is longer than textwidth
When I edit the portion of a line beyond textwidth, CPU usage spikes to 100%, and I have to kill Vim.
How to reproduce:
$ git clone https://github.com/ledger/vim-ledger.git /tmp/vim-ledger
$ cd /tmp/vim-ledger
$ git checkout aabf1976dfefe5665233c600421aea2798ff7ea0 # current master
$ cat <<'EOF' > test.journal
2025-07-01 starting balances
assets:cash $10 ; 100% CPU usage after appending any non-space character
equity:start $-10
EOF
$ vim -N -u <(echo "set runtimepath^=/tmp/vim-ledger | filetype plugin indent on | set tw=80 | set ruler") test.journal
# Go to end of the comment and type for example `a!`.
$ vim --version # nixos 25.05 vim-full Version: 9.1.1566
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 01 1980 00:00:00)
Included patches: 1-1566
Compiled by nixbld
Possibly related: #97 and #158.
Clearly that shouldn't be happening. I'm on the road right now with minimal ability to diagnose or fix this, but if anybody figures it out and can contribute a fix I'm happy to facilitate.
I still haven't had time to actually trouble shoot this, but I did repro it with your test MWE. I'll also note that I was able to get the same bad result in NeoVIM, so this isn't a VIM specific issue.
$ nvim -u NONE -c "set runtimepath^=/tmp/vim-ledger" -c "filetype plugin indent on" -c "set tw=80" -c "set ruler" test.journal -c "set ft=ledger"
Just one comment about recovering from this accident:
and I have to kill Vim.
You can get out of the pickle with CtrlC which cancels the hung shell process.