Instead of returning null when no hint has been selected, hinting.pipe
will now return a promise that will be resolved once a hint has been
selected or rejected if hintstate is destroyed without a hint being
explicitly selected by the user or if there are no hints to select.
Promise rejection is then handled at the end of excmds.ts:hint(), as
suggested by bovine3dom on Riot.
On SVG pages, trying to open the commandline results in an error. We
attempted to log this error using logger.error, which in turn tried to
open the command line. Recursion ensued.
This is fixed by not using the logger to log these errors to the. A
better solution could be to have the logger use the notification API to
tell the user about errors that happen while logging errors, but this
would require a new permission, which we shouldn't ask for until a
solution to https://github.com/cmcaine/tridactyl/issues/788 and
https://github.com/cmcaine/tridactyl/issues/708 is found.
This fixes https://github.com/cmcaine/tridactyl/issues/879.
In hinting.ts, pipe() and pipe_elements() assumed that the resolve
function they passed to hintPage() would always be called, which wasn't
always the case (e.g. when a users goes into hint mode but presses
`<Esc>`).
This caused unresolved promises to linger in the tab. When the tab was
closed, an error was thrown about the message manager being
disconnected. This was caught by Tridactyl and displayed in the command
line.
We're fixing this bug by passing no-op functions as onSelect to
hintPage() and explicitly passing the resolve function. The resolve
function is then saved in HintState and called when destroying
HintState.
We parametrize reset() in order to be able to distinguish between resets
caused by a hint being selected and by the user pressing `<Esc>`. This
is necessary because we need to know when the function should resolve
the last focused hint and when it shouldn't.
We then add a bunch of null handling in excmds.ts:hint() in order to
make sure not to introduce other bugs.
This fixes https://github.com/cmcaine/tridactyl/issues/855.
Now returns a tuple of the element and the number of hints available
when the function was run. This mainly fixes the rapid hint bug
encountered when the user enters rapid hint mode with only one link
available.
Another application idea would be modeline info or something in that
vein.
I don't quite understand how it worked at all without focusing the commandline first.
Peppered code with some more awaits as part of debugging and couldn't be bothered to test which were necessary.