Auto complete seems to fail for strings beginning with `:`
zxul767 opened this issue · comments
Willebaldo Gómez commented
I'm using the library as a submodule, with a snapshot at commit c9310ae.
It works great for completing regular words, but I recently added some commands that start with :
(e.g., :toggle-tracing
), and I noticed that the auto completion doesn't seem to work for those words. For example, after configuring as follows:
static char* const TOGGLE_TRACING = ":toggle-tracing";
static char* const EXIT = "exit";
static const char* COMMANDS[] = {TOGGLE_TRACING, EXIT, NULL};
static void
word_completer(ic_completion_env_t* input_until_cursor, const char* word)
{
ic_add_completions(input_until_cursor, word, COMMANDS);
}
static void
completer(ic_completion_env_t* input_until_cursor, const char* input)
{
ic_complete_word(
input_until_cursor, input, &word_completer,
NULL /* from default word boundary; whitespace or separator */
);
}
static void setup_line_reader()
{
setlocale(LC_ALL, "C.UTF-8");
ic_style_def("kbd", "gray underline");
ic_style_def("ic-prompt", "ansi-maroon");
ic_enable_hint(false);
// enable completion with a default completion function
ic_set_default_completer(&completer, NULL);
ic_enable_auto_tab(true);
}
If I type :
followed by TAB
, I get:
>>> :
1 exit
2 :toggle-tracing
However, if I type: :t
followed by TAB
, I don't get any completions.
Is this expected behavior, a bug, or am I doing something wrong?
Thanks!