Skip to content
Snippets Groups Projects
Commit ef7dd8db authored by Damien George's avatar Damien George
Browse files

py/repl: Fix case where shorter names are shadowed by longer names.

Previous to this patch, if "abcd" and "ab" were possible completions
to tab-completing "a", then tab would expand to "abcd" straight away
if this identifier appeared first in the dict.
parent 6ab8b63b
No related branches found
No related tags found
No related merge requests found
...@@ -187,7 +187,9 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t ...@@ -187,7 +187,9 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
match_str = d_str; match_str = d_str;
match_len = d_len; match_len = d_len;
} else { } else {
for (mp_uint_t j = s_len; j < match_len && j < d_len; ++j) { // search for longest common prefix of match_str and d_str
// (assumes these strings are null-terminated)
for (mp_uint_t j = s_len; j <= match_len && j <= d_len; ++j) {
if (match_str[j] != d_str[j]) { if (match_str[j] != d_str[j]) {
match_len = j; match_len = j;
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment