Autoformatter: avoid code being left in buf

issue #2540