rodjek / vim-puppet

Puppet niceties for your Vim setup
Apache License 2.0
500 stars 137 forks source link

with textwidth enabled, typing past the textwidth limit inverts the last two characters before formatting #135

Open lelutin opened 3 years ago

lelutin commented 3 years ago

This one's been bugging me for a good while now but apparently I never opened an issue about the problem! woops.

As described in the subject, when you have textwidth set to a certain value and you type past that limit, vim calls the formatting function and that currenlty has a nasty effect: the two last characters on the line get inverted before the formatting (so line re-splitting) happens. In the worst cases if the character before the last one is a space, the space gets inverted into the last posiion on the line and then the word before that ends up getting pushed to the next line even though it should've stayed on the same one.

I had previously narrowed down the problem to the call to gww in the formatting function.

I have a patch series for this which I'll send as soon as I finish writing this (I still wanted to open this issue to describe what's wrong with the current situation, e.g. what I'm trying to fix).