"Ensure trailing newline" not applied after onWillSave()

It seems that after modifying the contents of a TextEditor in an onWillSave() event handler will not apply the Nova saving settings for “Ensure trailing newline at the end of files” and “Automatically trim trailing whitespace”.

Here’s what I think is happening:

  1. Nova applies “Ensure trailing newline at the end of files” and “Automatically trim trailing whitespace”
  2. Nova calls onWillSave()

I would have expected it to be the other way around so that Nova applies it’s own saving settings AFTER any extension did their thing. If there was an option to get access to those settings an extension could apply those itself in the onWillSave() handler, but there is no such access.

I’m having this issue with the Beautify extension and its format on save feature.