Tab-completion: differentiate between "first option" and "no common prefix"
@@ -1180,14 +1180,8 @@ static void addAutocompleteOption(AutocompleteData* data, const char* option)
{
if (strstr(option, data->incompleteWord) == option)
{
- // The option matches the incomplete word, add it to the list.
- strncat(data->options, option, CONSOLE_BUFFER_SCREEN);
- strncat(data->options, " ", CONSOLE_BUFFER_SCREEN);
-
// Possibly reduce the common prefix of all possible options.
- if (strlen(data->incompleteWord) > 0)
- {
- if (strlen(data->commonPrefix) == 0)
+ if (strlen(data->options) == 0)
{
// This is the first option to be added. Initialize the prefix.
strncpy(data->commonPrefix, option, CONSOLE_BUFFER_SCREEN);
@@ -1205,7 +1199,10 @@ static void addAutocompleteOption(AutocompleteData* data, const char* option)
*tmpCommonPrefix = 0;
}
- }
+
+ // The option matches the incomplete word, add it to the list.
+ strncat(data->options, option, CONSOLE_BUFFER_SCREEN);
+ strncat(data->options, " ", CONSOLE_BUFFER_SCREEN);
}
}
