meraymond2/idris-ide-client

Reconsider return type of loadFile

Opened this issue · 0 comments

My initial idea was that each command would only return the final reply generated, but to provide the flexibility to listen to all replies, so that consumers could still access intermediate replies. I'd need to double checked, but in practice, I don't think any commands besides loadFile produce intermediate output.

The current setup isn't very convenient though.

  • If the consumer wants to do something after loading all the source highlighting (:output messages), you need to use the listener, and collect them asynchronously, and also listen for the final reply to know when it's finished.
  • It's difficult to map those responses to a specific request, because you don't get the request message id until the promise resolves, at which point some of the :output messages will have already come in.
  • If you have a listener for :output messages, it's not guaranteed to have received all of them before the loadFile promise resolves, due to the way node interleaves the function calls.

I'm leaning towards just making the :load-file request a special case in the client, and aggregating all of the :warnings and :outputs into the reply. I think it would simplify the consumer code significantly, if you could just access an array of warnings and source-highlighting when the promise resolved.