Closed mjhenkes closed 9 years ago
For passivity I added a new menu item "enable format on build" which is dependent on "enable format on save". I'm swizzling a method at a lower level on NSDocument to catch the save when code is built versus just the save command.
i don't like the menu options being dependent.
if i have enabled it to format on build then it should format on build. similar with format on save, if that's enabled then it should format on save.
@travisjeffery, Having the menu options not dependent is fine but i'll have to introduce some weirdness in the code since I'm swizziling save at a lower level. I'll have to add some kind of flag to indicate where the save is coming from (an explicit save or not). I had format on build dependent on format on save because really both are formatting on save, just through different routes.
I'd actually prefer just to have format on save automatically format on build, but i was trying to be passive.
oops
@travisjeffery, what would you think of automatically formatting on build when format on save is enabled. Trying to make format on build not dependent on format on save introduces some weirdness in behavior. For example: Format on save is disabled. Format on build is enabled. User edits code. User explicitly saves. User builds code. The code is not formatted because the build does not fire the "saveToURL" call I'm swizzling because there is nothing to save.
no. format on save current behavior is useful for people who want to know how the code look after formatting.
do we know if we're building or not? i can't tell by your code how we know if we're building or not. if we do know then the checks to see if we should format given the user's preferences can be separate.
Unfortunately no we do not know if we are building or not. The current implementation is driven completely of saving before building. Which leads to part of the problem. If the code doesn't need to be saved before building it is not formatted. Also if we didn't rely on formatting only the files that need to be saved on build we would end up formatting the entire project... This issue and the desire to allow people to only format on save and not on build drove my first implementation to have format on build dependent on the user first selecting to format on save. My terminology may have been off. Really I'm trying to enable "format on save when a file happens to be saved just before building"... but thats kinda wordy
Fixes #13