machakann / vim-sandwich

Set of operators and textobjects to search/select/edit sandwiched texts.
1.44k stars 37 forks source link

Incorrect behaviour with formatoptions=t #70

Closed olmokramer closed 5 years ago

olmokramer commented 5 years ago

The correct text is not sandwiched when any of the edits by vim-sandwich causes a reformatting due to the line being too long.

Reproducer:

  1. Open vim without a file: $ vim
  2. Run :setl fo+=t tw=10 (formatoptions is now tcqn1j for me)
  3. Paste this text: ab cd ef gh ij kl mn op
  4. Position the cursor between the k and the l
  5. Run saiw(

The output is now

ab cd ef)
gh ij (kl mn op

Note that the closing parenthesis is placed incorrectly.

machakann commented 5 years ago

Thank you for your report. This is a bug.

I think it is reasonable to suppress autoformatting in a surrounding operation. I fix this problem soon.

olmokramer commented 5 years ago

Thanks for the quick reply!

I think it is reasonable to suppress autoformatting in a surrounding operation.

Yeah that's what I thought as well. You should probably also disable formatoptions=c. Or were you planning on unsetting 'formatoptions' altogether?

machakann commented 5 years ago

Yes, exactly. I think formatoptions would be better to be empty in a operation.

machakann commented 5 years ago

I wrote the wrong number in the commit message... But, I think this is fixed by 558b858 . Could you update and test it?

olmokramer commented 5 years ago

That was fast! Seems to work yes, thanks!