Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's a bunch here and I'm happy to explain any of it. I also totally understand if this is not a solution you're looking for. Feel free to use this as inspiration for a different solution. I won't be offended at all.
When saving a document, Nova would save the file, then Black would
apply the formatting after the save. This left the document as unsaved
after an explicit save. To ensure that nova waits for the Black
process to finish, Nova's onWillSave method needs to return a Promise.
It will wait for 5 seconds while that promise resolves, ensuring that
the document will be reformatted first and saved second. This refactor
attempts just that.
The main refactor is around the execute method of BlackProcess and the
format method of Formatter. execute now returns a promise. If the
promise resolves, it passes the formatted text to the formatter, which
calls the edit function on the document to make the change. If the
promise rejects it represents a failure in some way. The formatter
catches this rejection and creates a notification for the user. It's
often (but not always) the case that the error is something the user
would want to know about, like a malformed python document.
This also
didExit
from BlackProcessFixes #1