summaryrefslogtreecommitdiffstatshomepage
path: root/py/repl.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/repl.c')
-rw-r--r--py/repl.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/py/repl.c b/py/repl.c
index 649ade161b..736dfa3f69 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -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;