It looks as though the trim is taking place AFTER saving, instead of BEFORE. This means whenever the plugin removes whitespace during a save, it immediately creates further unsaved changes on the file and I effectively have to save twice. That, or dismiss the "Save before closing?" prompt when closing the file.