This fixes https://github.com/cmcaine/tridactyl/issues/613.
This was a really fun bug. What happened was this:
- First, the content script set state.mode to "hint", which was then
synchronized
- The event listener in the background script noticed the update and set
state.mode to "hint" in the background script
- Then, the content script translated the hint selection into an excmd
that needed to be executed in the background script and sent said
command to the controller, which lives in the background script
- The content script then set state.mode to "normal"
- The background script executed the command and saved it in
state.last_ex_str, which was then synchronized
- The event listener in the content script noticed the update and set
last_ex_str to the last executed str and "state.mode" to "hint"
So basically, the problem was that the background script didn't notice
the state.mode update right after it happened. I fixed this by moving
last_ex_str out of "state" since it doesn't need to be synchronized with
the content script.
This means that the same kind of race condition can still happen. I'm
not sure how to fix this. We could just kill state completely and
instead have state be updated through message passing, but this probably
wouldn't be very ergonomic.
Another solution, the one envisioned for Tridactylv2, is to move to the
content script entirely. This is probably the best option.
When trying to run scripts/pretty with multiple ugly files staged, the
for loop would treat two space-separated file names as a single file
name. This prevented pretty from working on my machine.
I fixed this issue by making cachedJS() (renamed to cachedFiles since it
returns more than js files) return file names as a newline-separated
list and using IFS=$'\n' to split the filenames on this character.
Before this patch, navigating to a new page made Tridactyl scroll to its
very top. This broke jumping to the definition of a command using `:help
commandname`.
This fixes https://github.com/cmcaine/tridactyl/issues/565
I chose to append a TridactylInvisible class instead of setting the
modeindicator setting to false or manually removing the element from the
DOM because this seemed more robust (e.g. when "modeindicator" is set to
true, you expect it to stay set to true and for the element to exist
within the DOM).