Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Compile while typing #26

Closed
tomitrescak opened this issue Aug 15, 2016 · 7 comments
Closed

Compile while typing #26

tomitrescak opened this issue Aug 15, 2016 · 7 comments

Comments

@tomitrescak
Copy link

In #8 you mention the possibility of having compilation while typing. This would be a great help as now I have to save file always when compiling. The other plugin for vscode-flow has this feature enabled, but other than that it's pretty useless as it make a lot of errors. Your plugin works very nice, but misses this feature. Any possibility of implementing this? Thanks for all the work!

@nmote
Copy link
Contributor

nmote commented Aug 29, 2016

See facebookarchive/nuclide#604 for my explanation on why this is difficult to get right with the current state of things. I've added the necessary changes to Flow. Some restructuring has to be done to take advantage of them in Nuclide and I'm not sure when I'll have time for it. But once I do someone should be able to update this plugin to take advantage of those changes.

@orta
Copy link
Contributor

orta commented Dec 6, 2016

@nmote this looks unblocked from the flow side - is it? if so, would this work by piping the current (potentially unsaved) document's text to flow check-contents an then working against the response?

@minedeljkovic
Copy link
Contributor

if so, would this work by piping the current (potentially unsaved) document's text to flow check-contents an then working against the response?

I'm not sure how this would work if that file (module) imports other modules.

@nmote
Copy link
Contributor

nmote commented Dec 6, 2016

Yeah, with the right flags to check-contents you can do this now, with a couple caveats:

  1. check-contents reports errors for the given file based on other files' contents on disk. so, if you have multiple unsaved files in your editor you will get inconsistent errors
  2. you still need to call flow status after a save to make sure you get the errors in other files that have been introduced by the changes to the current file
  3. when you get those results back from flow status you need to remember which files are currently unsaved and don't update the results for them

None of this is particularly hard but I just haven't gotten around to it yet. It might be a nice little end-of-year project though so I'll try to slot it in in the next couple weeks. Then you can just copy the code from Nuclide.

Also, if you don't care about handling the multiple-unsaved-file case gracefully, then this is really easy.

@nmote
Copy link
Contributor

nmote commented Dec 6, 2016

Oh, and @minedeljkovic: there's a --file argument (or similar) to check-contents that allows Flow to properly resolve other modules, since it knows where the given file lives.

@orta
Copy link
Contributor

orta commented Dec 6, 2016

Cool, thanks!

@nmote
Copy link
Contributor

nmote commented Dec 14, 2016

I've decided to change tack. Instead of cobbling together a solution with the caveats above I'm going to develop a way for editors to maintain a persistent connection to Flow. This will solve a bunch of problems well, and longer-term will make it easier for us to present errors as you type without the caveats listed above. Rather than invest effort in a short-term solution I'm going to pursue this longer-term solution. Unfortunately the first steps will not allow for errors as you type, but hopefully it's available in about 3-4 months.

In the mean time, anyone who is interested is welcome to implement the short-term solution described above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants