I'm often tripped up by the fact that only the current file is formatted when doing a Save All. Other files that have changed are saved, but are not touched by prettier-atom. Is this something you've considered addressing, or even possible to be addressed?
Hey @tacomanator, no I hadn't considered that as I just personally haven't ever used that functionality. I don't have a problem with addressing this scope-wise, but I would need to look into if and how this could be addressed and how big of a change it would be.
I see. It's useful on projects using some sort of live reload. It's usually desirable to save all at once when making a change that spans multiple files, to avoid a premature reload. If it's doable, that would be 馃憤
can i work on this
@lemon79 sure!
@lemon79 Thanks for your help 馃憤
If you're stuck or need a little guidance, don't hesitate to ask.
hey i have no clue how to do this, i think to trigger the format there has to be an event listener for save all, but i can't find out how to attach it to the atom element.
@lemon79 The subscription on save is done in main.js.
I never really paid attention to this part, but it looks like we already subscribe to the save event on every text buffer, and this might actually be a bug.
As you can see, we call lazyFormatOnSave(editor) before every save, but the implementation does:
const editor = atom.workspace.getActiveTextEditor();
if (editor) formatOnSave(editor);
and it ignores the editor passed as an argument, so you can try fixing that and see if it solves the issue.
@robwise I'm not sure why this wasn't detected by one of our tools.
Is this something Flow or ESLint is supposed to catch? (looks like Flow is not enabled for main.js)
@darahak i tried to save every editor, but then it cannot distinguish between save and save all
@lemon79 Not sure I understand what you mean. What did you do exactly?
@robwise I'm not sure why this wasn't detected by one of our tools.
Is this something Flow or ESLint is supposed to catch? (looks like Flow is not enabled for main.js)
Sorry for the delay in responding, I was moving out of my place the past two days. You're absolutely right, we should use the passed editor and not make the getActiveTextEditor() call. I think Flow only added detection for this in 0.47.0 and we're still on 0.46.0
Eslint will error if you declare a function parameter but don't use it, however, here we do not declare the function param when declaring the function, and eslint is not smart enough to go look at the invoking code.
i tried to save every editor, but then it cannot distinguish between save and save all
Like darahak, I'm not entirely sure what you mean, but if you're saying that you can't tell if you're performing a save or a save all, yet the end result is the same, maybe that's okay? You might even argue it's more elegant that way.
@lemon79 Are you still working on this? Need more help?
Most helpful comment
@lemon79 sure!