Closed rageandqq closed 6 years ago
RE using a lib
folder: sgtm. Will add that in the next diff (needs
The symlinking is a good idea - I didn't want to spend too much time on it earlier so I just had a build script (that I later changed to a Makefile). I'll try to set that up before merging this PR.
Yeah no rush on those changes (can both be done separately). Especially since we will need to share those utilities with the neovim plugin too.
This won't fully work yet, but it's a start. It works with the version of the tandem agent from just before the write request work was added.
How it works:
/users/${User}/Library/Application Support/Sublime Text 3/
to load. TheMakefile
currently does this (see README), but needsroot
access. The crdt, agent, and enum dependencies are copied as well (directories made if required).Ctrl+backtick
. Runview.run_command("tandem")
to start (start as a host for now, joining as a listener support to come).view.run_command("tandem_stop")
to stop. If you look at the code, there is no binding between the string and the command - this is done automagically. The command string is converted from snake case to camel case, sotandem_stop
invokes theTandemStopCommand
.Additional notes:
enum-dist
, this is all library code.edit.py
file is a helper for ST3. Basically, modifications to the buffer require access to anEdit
object - used by Sublime internal to group modifications to the buffer so that undo/redo can be handled well.edit
references are only received on commands and listener events. We need a reference to edit in order to make changes to the buffer. However, if you retain a reference to anedit
instance, and use it in thehandle_message
method to try to apply a patch, it errors. This is becauseedit
instances are unique and cannot be shared/re-used. The alternative approach here is to use view commands (like what we used to invoke the start/stop commands), and this works since we can hang on to the reference of theView
that we get (aView
is basically the open tab). UnfortunatelyView
only supports insert and delete, and notreplace
which is ideal for our needs. This utility helps converting replace (and other API if we need it) to view commands. Sorry for the long write-up, I thought it necessary.I will work on bringing this up to par with the state of [neo]vim in future diffs, namely adding support for the write request and write request ack features.
Also, this won't be super resilient to text buffer changes while processing messages from the agent as noted above, but that can also be added in later.