The problem
When the user issues multiple cursorless commands in one talon phrase, we use a debounce to ensure that the decorated marks they are referring to still exist. This mechanism is not flawless, and sometimes breaks for longer phrases
The solution
Talon side
- phrase_pre sets a flag indicating that phrase has started and barrier needs to be sent
- look actions such as mouse and key and override them, as well as command_client.vscode so that if flag is set, it sends barrier and clears flag. in all cases it then runs
actions.next
Extension side
- When vscode receives the barrier, it will make a copy of navigation map
- When it receives a reference to a decorated mark, it will always use the copy of the navigation map
- If barriers aren't being sent, might want to throw an error of some sort
The old solution
Note: the problem with this solution is that it requires cross-process reliable timestamps, which is challenging. If we did go this route, we'd need to make sure that the monotonic clock used by Node.js is the same as that used by the word timestamps in Talon. In case we go this route, here is some information that might be helpful:
Node.js monotonic clocks
From what I can tell, to get monotonic time in node.js, you’re supposed to use a function called process.hrtime.bigint(). It looks like that function is … mapped to the function uv_hrtime from libuv. That function is defined differently on different processes:
I’m still not in love with sending that barrier every time we issue any command in VSCode, but also have mixed feelings about using timestamps across process boundaries that are only supposed to be used for performance measurements. Guessing we prob still should go the barrier route but if these clocks are the same as those used by talon, maybe it’s worth a try to use word timestamps?
Here's the solution below, if we went this route:
Talon side
We'd like to have talon use the momentary-style word timing information to send a timestamp alongside every decorated mark. Inside the cursorless_decorated_symbol capture, we could just get the timing information off of the match object (m) and pass it through the json blob here
We should fallback to just using current timestamp in that function if word alignment not available, eg not on beta
Extension side
Cursorless will need to keep track of previous token maps along with the time range they existed, and also keep them up to date as the document changes. We could probably just use a debounce to expire them, eg any old decoration map will expire after 5 seconds or something.
Then when we get a command that uses a decorated mark, we just use the token map that existed at the given timestamp
The problem
When the user issues multiple cursorless commands in one talon phrase, we use a debounce to ensure that the decorated marks they are referring to still exist. This mechanism is not flawless, and sometimes breaks for longer phrases
The solution
Talon side
actions.nextExtension side
The old solution
Note: the problem with this solution is that it requires cross-process reliable timestamps, which is challenging. If we did go this route, we'd need to make sure that the monotonic clock used by Node.js is the same as that used by the word timestamps in Talon. In case we go this route, here is some information that might be helpful:
Node.js monotonic clocks
From what I can tell, to get monotonic time in node.js, you’re supposed to use a function called process.hrtime.bigint(). It looks like that function is … mapped to the function
uv_hrtimefrom libuv. That function is defined differently on different processes:QueryPerformanceCounteron Windows,mach_absolute_timeon Darwin,clock_gettime(CLOCK_MONOTONIC, &ts)for generic posix.I’m still not in love with sending that barrier every time we issue any command in VSCode, but also have mixed feelings about using timestamps across process boundaries that are only supposed to be used for performance measurements. Guessing we prob still should go the barrier route but if these clocks are the same as those used by talon, maybe it’s worth a try to use word timestamps?
Here's the solution below, if we went this route:
Talon side
We'd like to have talon use the momentary-style word timing information to send a timestamp alongside every decorated mark. Inside the
cursorless_decorated_symbolcapture, we could just get the timing information off of the match object (m) and pass it through the json blob hereWe should fallback to just using current timestamp in that function if word alignment not available, eg not on beta
Extension side
Cursorless will need to keep track of previous token maps along with the time range they existed, and also keep them up to date as the document changes. We could probably just use a debounce to expire them, eg any old decoration map will expire after 5 seconds or something.
Then when we get a command that uses a decorated mark, we just use the token map that existed at the given timestamp