This commit removes the try/catch in the excmd completion source and
instead makes the ExcmdCompletionOption constructor default to a string
for missing values.
This is useful for three reasons:
- The try/catch discarded excmds that didn't have a type/documentation,
but being able to autocomplete the name of these functions could still
be useful
- Try/catch are usually expensive
- TypeScript wrongly complained about a missing parenthesis when the
try/catch was there
Changes to the help page's layout can break the embedding of settings
into it. We fix this by making sure the CSS path selected doesn't depend
on the DOM hierarchy.
This implements excmd completion. We're using the typescript compiler
API in order to get the documentation and the type of every function of
Tridactyl and generate a file named "src/metadata.ts" which contains
this information. Since this file is dependency-less it can be imported
from every source file.
We then write a regular completion source which just uses the data
contained in metadata.ts in order to generate its completions.
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.