Presave not guaranteed to happen before saving.
Push Configuration:Preferences:Toggle Trim Whitespace On Save into Sandbox.