Nothing above worked for me. The issue it was causing was it trimming white space after save, turns out there is a separate setting for that and formatOnSave does not override this.
go to settings and disable Files:Trim Trailing Whitespace, this worked after hours of fixing it