This improves the experience of e.g. pressing b<Tab> as it means
that it will, within reason, wait until the completions have been
populated before firing
The completion uses Fuse.js to match user filter. The matching is fuzzy,
therefore sometime looks weird. The results are much easier to follow by
putting better matched results at the top.
This rule requires adding a new set of rules, tslint-etc.
no-unused-declaration used to be available in tslint:recommended but was
deprecated when --noUnusedVariables was added to typescript. The problem
with using TypeScript's --noUnusedVariables is that it turns unused
declarations into an error and prevents compilation, which isn't fun
when you're just prototyping things.
Before this commit, Tridactyl had a bug where resizeArea could be called
before completion computation had ended, which resulted in completions
pushing the input field out of the viewport (easy way to reproduce this:
open a lot of tabs and press `b` to open buffer completions).
This happened because for some of the completion sources, `filter`
returned before completion computation had actually ended. This is fixed
by making sure that filter() (and all underlying calls to updateOptions,
onInput, updateChain...) return a promise that will only be resolved
once completion computation has actually ended.
One of the problems of the command line was that it made a resizeArea()
call for each enabled completion, no matter whether its status was
"hidden" or "normal". This was a problem because a resizeArea call
results in 2 cross-script messages: a "show" and a "focus" message. This
means that for each keystroke, we sent 28 messages. This commit fixes
that thanks to modifications in multiple files:
- commandline_frame.ts: Stop accumulating event listeners on resizeArea
calls. Make sure completion sources actually need a refresh before
calling resizeArea().
- completions.ts: Add logic to know whether a completion source needs a
refresh or not.
- {Rss,Sessions,Tab,TabAll,Window}.ts: Make sure that completions are
actually needed before computing them.
This seems to make opening the command line slightly faster for me,
although I can't tell if this is placebo or not.
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 commit removes an if statement that is always true and a caching
optimization that can go wrong.
The caching optimization is the `if (!this.fuse)` statement. This
optimization can be buggy because it relies on this.options not
changing between two calls to scoredOptions but as far as I can tell,
this.options always changes between two scoredOptions calls.
If this.options changes, the array indexes used in searchThis do not
point to the right elements anymore and everything can break
(completions that should be matched disappear, completions with a lower
score get higher priority etc).
As far as I can tell, removing this optimization does not make
completions slower, but I couldn't test this with a large history.