As mentioned in https://github.com/cmcaine/tridactyl/issues/912, there
was a problem with aliases preventing some excmd completion options from
being displayed. For example, `b` would be expanded to `buffer` in the
command line completion mechanism and thus prevent `back` from being
displayed.
This commit fixes that by treating aliases as "real" excmds when
building completion sources. Basically, we check for aliases to the
prefixes given as CompletionSource parameter and add them to the list of
prefixes that can trigger the completion source.
We use this opportunity to remove the constraint of having to add a
space to each prefix, they're instead automatically added by the
CompletionSource constructor.
Rapid hinting now returns an array. When no hints have been selected, an
empty array is returned. When no hints have been selected in regular
hinting mode, an empty string is returned.
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.
The minimal userChrome file causes 8 pixels to be cut off from the top of the "content" part of the page, but only when the navbar is hidden. This change, as written, will reverse the situation: it will add 8 pixels of extraneous padding when the navbar is not hidden. Given that we spend most of our browsing time with the navbar hidden, this optimises for the common case instead of the uncommon case.
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.
Making hint mode less janky is achieved by not resetting hint mode when
a hint has been selected. New command line options, `-q*` where `*`
stands for any alread-existing flag, are added.
The global hint flow is as following:
- User goes into hint mode
- hint mode promise is created
- When a hint is selected, the corresponding action is performed (e.g.
opening a link, killing an element...)
- The result of the action is saved in the hint
- If we're not in rapid hint mode, modeState is reset, and the hint mode
promise is resolved with the result of the action as parameter
- If we're in rapid hint mode, modeState is not reset. Instead its
filter is reset and all its hints are displayed again.
- Rapid hint mode is only left on escape, and this means that the
promise will be rejected.
Rejecting the promise means that we can't pipe elements selected in hint
rapid hint mode to other commands. This makes sense because pursuing
execution of a pipe several times in parallel, on top of being possibly
hard to implement, would probably be confusing.
Instead of using a pipe in order to execute arbitrary commands in hint
mode, users can use `-qW excmd`. Contrary to the pipe, this makes clear that
the excmd will be executed multiple times, once per focused hint.
This way of handling rapid hint mode has the advantage of simplifying
the `hint` function. Now, instead of having to return a tuple with the
number of available hints, the function can just return the selected
element or whatever the command line arguments specifies it should
return.