Function LineGetter.tabComplete
Override this to provide tab completion. You may use the candidate argument to filter the list, but you don't have to (LineGetter will do it for you on the values you return). This means you can ignore the arguments if you like.
string[] tabComplete(
in const(dchar[]) candidate,
in const(dchar[]) afterCursor
);
Ideally, you wouldn't return more than about ten items since the list gets difficult to use if it is too long.
Tab complete cannot modify text before or after the cursor at this time. I *might* change that later to allow tab complete to fuzzy search and spell check fix before. But right now it ONLY inserts.
Default is to provide recent command history as autocomplete.
Both candidate and afterCursor may have private data packed into the dchar bits
if you enabled [enableAutoCloseBrackets]. Use ch & ~PRIVATE_BITS_MASK to get standard dchars.
Returns
This function should return the full string to replace
candidate[tabCompleteStartPoint(args) .. $].
For example, if your user wrote wri<tab> and you want to complete
it to write or writeln, you should return ["write", "writeln"].
If you offer different tab complete in different places, you still
need to return the whole string. For example, a file completion of
a second argument, when the user writes terminal and you
want it to complete to an additional terminal, you should return
["terminal.d terminal.d"]; in other words, candidate ~ completion
for each completion.
It does this so you can simply return an array of words without having to rebuild that array for each combination.
To choose the word separator, override [tabCompleteStartPoint].
Parameters
| Name | Description |
|---|---|
| candidate | the text of the line up to the text cursor, after which the completed text would be inserted |
| afterCursor | the remaining text after the cursor. You can inspect this, but cannot change it - this will be appended to the line after completion, keeping the cursor in the same relative location. |
History
Prior to January 30, 2020, this method took only one argument,
candidate. It now takes afterCursor as well, to allow you to
make more intelligent completions with full context.