After taking quite some time in understanding Xray and Memo implementation, I understood that instead of focusing on smaller tasks, the best way to proceed was actually to implement the latter into the editor's core.
First of all I had to expose some more methods from Memo's WorkTree: max_point, clip_point, longest_row, line, iter_at_point, len and len_for_row. Those methods are especially needed in BufferView in actions like editing and moving selector around the buffer.
I initially started dividing the Buffer into Local and Remote, communicating over RPC like other modules of Xray already do. For the local buffer, the idea was to implement a wrapper around Memo's WorkTree like the JavaScript implementation suggests, while the remote gathering information about it, as said, over RPC - I soon dropped this implementation because I thought would end up being to much network intensive.
To solve the issue above, I decided to implement the WorkTree for both Local and Remote buffers, sharing the same ReplicaId and exchanging only Operations over RPC: this make the communication way easier. I created a really inefficient storage where I broadcast operations (I still have quite some problems with that actually). The big issue is that the Remote Buffer is not working at all 😅WASM is building, but when opening a file... Well it panics – I think this may be connected in resolving some Futures or Streams with .wait() but still, not sure (that seems to make the app panic w/o great explanation – I had hard time understanding that).
Both implementation in https://github.com/fdionisi/xray/tree/implement-memo and https://github.com/fdionisi/xray/tree/implement-memo-2 are faulty and incomplete and I may start with a third option consolidating the work done around the storage idea, but I would like to share those with the community, and hopefully somebody could give me some ideas on how to proceed, or an approach I am not seeing at the moment.
Tests have been commented out, due to deep changes in the code base, I should perhaps start from there 😅
After taking quite some time in understanding Xray and Memo implementation, I understood that instead of focusing on smaller tasks, the best way to proceed was actually to implement the latter into the editor's core.
First of all I had to expose some more methods from Memo's WorkTree:
max_point,clip_point,longest_row,line,iter_at_point,lenandlen_for_row. Those methods are especially needed inBufferViewin actions like editing and moving selector around the buffer.I initially started dividing the Buffer into
LocalandRemote, communicating over RPC like other modules of Xray already do. For the local buffer, the idea was to implement a wrapper around Memo's WorkTree like the JavaScript implementation suggests, while the remote gathering information about it, as said, over RPC - I soon dropped this implementation because I thought would end up being to much network intensive.To solve the issue above, I decided to implement the WorkTree for both Local and Remote buffers, sharing the same ReplicaId and exchanging only Operations over RPC: this make the communication way easier. I created a really inefficient storage where I broadcast operations (I still have quite some problems with that actually). The big issue is that the Remote Buffer is not working at all 😅WASM is building, but when opening a file... Well it panics – I think this may be connected in resolving some Futures or Streams with
.wait()but still, not sure (that seems to make the app panic w/o great explanation – I had hard time understanding that).Both implementation in https://github.com/fdionisi/xray/tree/implement-memo and https://github.com/fdionisi/xray/tree/implement-memo-2 are faulty and incomplete and I may start with a third option consolidating the work done around the storage idea, but I would like to share those with the community, and hopefully somebody could give me some ideas on how to proceed, or an approach I am not seeing at the moment.