diff options
author | Damien George <damien.p.george@gmail.com> | 2015-07-06 14:00:09 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-07-06 14:00:09 +0100 |
commit | ef7dd8db2dc6816d303b4f5b10b99b98b11b3ed5 (patch) | |
tree | 5a2282df0da2a90f5f30eb47f28e4f7286082abf /py | |
parent | 6ab8b63bdd8c640e09156b81983742e60d88a0cd (diff) | |
download | micropython-ef7dd8db2dc6816d303b4f5b10b99b98b11b3ed5.tar.gz micropython-ef7dd8db2dc6816d303b4f5b10b99b98b11b3ed5.zip |
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.
Diffstat (limited to 'py')
-rw-r--r-- | py/repl.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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_len = d_len; } 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]) { match_len = j; break; |