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.
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.
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.
This is useful for suppressing spew, but still allowing easy debugging
when needed, without rebuilding.
To use, use excmd:
setlogginglevel <prefix> <level>
Where the level is one of:
- never: never log
- error
- warning
- info
- debug: most verbose
Output is directed to console methods "error", "warn", "log", "debug".
Done:
Working completion for buffers
Substitute values into command line
Prepare for non-buffers completions
Wrote too many classes and helper functions
Todo:
Learn inferno and hopefully simplify
If not, simplify the main functions so that people can actually
build for it.
Define an interface for tabbing through options
Allow more than one CompletionSource per command
This commit squashes a load of work by @Koushien, a dozen hours from
@cmcaine and some CSS by @bovine3dom.
@cmcaine is writing this commit message, but the work was mostly by
Koushien so the author is set to them. Thanks Koushien!
The following issues need to be fixed:
- The interface is over complicated (my fault)
- commandline_frame is hard-coded to use BufferCompletionSource. This
needs to be made more general
- BufferCompletionSource should be generalised
- completions.ts calls helper functions in commandline_frame. Should
just use browser proxy. If that's too slow can define a
completions_background.ts
After that's done, this should be fixed:
- Completion hiding/unhiding is currently too messy.