Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Wait for promises returned by onWillSave handlers before saving - #254

Merged
maxbrunsfeld merged 1 commit into
masterfrom
mb-async-on-will-save-hook
Sep 12, 2017
Merged

maxbrunsfeld merged 1 commit into
masterfrom
mb-async-on-will-save-hook

Conversation

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

@stevenzeck

Copy link
Copy Markdown

Hi @maxbrunsfeld, does the promise simply need to be returned or does it have to be resolved? I'm finding that returned rejected promises it's not saving the content of the buffer, though coffeescript isn't my favorite thing and could be a coding issue. Also looking at the docs here: https://atom.io/docs/api/v1.21.1/TextBuffer#instance-onWillSave it does say it will not save until the promise is resolved.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor Author

We will now wait until promises returned from ‘onWillSave’ listeners to resolve before saving the file. If the listeners return a promise that rejects, then ‘buffer.save’ will reject with that error, and the file will not be saved.

@stevenzeck

Copy link
Copy Markdown

OK thanks, one more question. Is it possible to get the file path, or at least the file name and extension, after the save prompt for a file that hasn't been saved yet during onWillSave? Basically:

  1. Create new file
  2. Add some content
  3. Save it (save prompt appears)
  4. Give the file a name/extension and where to save it

That all occurs before any onWillSave code is run, but I can't find any reference to what the user puts in there.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor Author

Hmm, I don't think you can access that data currently. It would be possible to add it as an argument to the onWillSave listener though. Are you interested in submitting a PR to do that?

@stevenzeck

Copy link
Copy Markdown

I could try, I've never looked at this code before nor actually built Atom locally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants