update functions in configLocalWorkingDir
urbanslug opened this issue · 6 comments
As it stands we cannot update the session while using configLocalWorkingDir. This is due to this: https://github.com/fpco/ide-backend/blob/master/ide-backend/IdeSession/Update/ExecuteSessionUpdate.hs#L602 I am working on making it possible to update the session while using configLocalWorkingDir.
If anyone has any pointers on how to solve this (or believes it can't be done with configLocalWorkingDir) I would appreciatea heads up. Thank you.
The session can be updated, just not with the file commands. I'm not sure if this is the right choice, but the reason for it is to avoid potential confusion over who's writing files. Why would you send the file to the backend if you can just write to it? Best to leave writing to the local filesystem to the user's editor. If you want ide-backend to check for file updates, send an empty list of session updates.
It would be interesting to be able to use the file update commands to temporarily shadow the versions of the file that are in the file system. This would allow the IDE to send the buffer version of a module, while leaving the filesystem untouched. I'm thinking it would be easy to support this, but I'm not 100% sure.
Thank you for your help.
However, I might be misunderstanding what you mean by "send an empty list of session updates". The type IdeSessionUpdate
is not a list of updates so what do you mean by send an empty list of session updates?
I tried it a different way and set my update as an empty list of Args updateArgs []
since that shouldn't require a session restart https://hackage.haskell.org/package/ide-backend-0.10.0/docs/IdeSession.html#v:updateArgs . This lost what was in my updateTargets
and updateGhcOpts
. Am I missing something?
Here is the code: https://gist.github.com/urbanslug/e232e3a83cfab99039f1
Yes the "shadowing" method of updating a session is what was in my mental image or something but I was thinking more like using backup files. It's not very clear in my head yet.
However, I might be misunderstanding what you mean by "send an empty list of session updates"
Ah, good point! I'm used to it being a list because that's the API stack-ide provides. Its list-iness is from its Monoid instance. Use mempty
to pass an empty session update.
This lost what was in my updateTargets and updateGhcOpts. Am I missing something?
That update shouldn't affect targets / ghc opts. That could be a bug. What's the evidence that it lost those?
Here is the proof https://gist.github.com/urbanslug/7501dc51f21a3bbfe4d5. The error is usually fixed by setting targets which was done previously (https://gist.github.com/urbanslug/e232e3a83cfab99039f1#file-compile-hs-L20) so somehow the previously targets have been affected/flushed.
edit this might be my fault. Will get back to you.
Yes it was definitely mine but don't close this issue just yet. There are a few things I need to get clear.
No it definitely works. Maybe this info can be added in the code as a comment or the wiki? However, another problem arises. It rebuilds but not with Template Haskell dependencies. It doesn't rebuild the source files that callthem if a change is made in the TH file. Better explained here: urbanslug/wai-devel#6 (comment)
I'll close this issue because update functions aren't allowed in configLocalWorkingDir. If one is to add such functionality somehow, they should file for an enhancement but this is not a valid bug. Thank you.