vim-ledger icon indicating copy to clipboard operation
vim-ledger copied to clipboard

100% CPU usage when appending a non-space character to a comment that is longer than textwidth

Open thomie opened this issue 4 months ago • 2 comments

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.

thomie avatar Aug 24 '25 08:08 thomie

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.

alerque avatar Aug 26 '25 05:08 alerque

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.

alerque avatar Sep 22 '25 21:09 alerque