lib: Check match level when calculating completions

Adds a missing check that resulted in partial token
matches being accepted as exact matches when calculating
input completions.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2016-10-06 00:03:39 +00:00
parent b4f56274fa
commit 03ca8d3dff

View File

@ -328,6 +328,7 @@ command_complete (struct graph *graph,
for (ALL_LIST_ELEMENTS_RO (current,node,gn)) for (ALL_LIST_ELEMENTS_RO (current,node,gn))
{ {
struct cmd_token *token = gn->data; struct cmd_token *token = gn->data;
enum match_type minmatch = min_match_level (token->type);
#ifdef TRACE_MATCHER #ifdef TRACE_MATCHER
fprintf (stdout, "\"%s\" matches \"%s\" (%d) ? ", input_token, token->text, token->type); fprintf (stdout, "\"%s\" matches \"%s\" (%d) ? ", input_token, token->text, token->type);
#endif #endif
@ -347,6 +348,8 @@ command_complete (struct graph *graph,
listnode_add (next, gn); listnode_add (next, gn);
break; break;
} }
if (minmatch > partly_match)
break;
case exact_match: case exact_match:
#ifdef TRACE_MATCHER #ifdef TRACE_MATCHER
fprintf (stdout, "exact_match\n"); fprintf (stdout, "exact_match\n");