Skip to content

Commit 682b06a

Browse files
committed
repl: Don't autocomplete globals after "import ".
Originally at adafruit#4608 Signed-off-by: Artyom Skrobov <[email protected]>
1 parent a73c337 commit 682b06a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

py/repl.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
281281
++str;
282282
}
283283

284+
// after "import", suggest built-in modules
285+
static const char import_str[] = "import ";
286+
if (len >= 7 && !memcmp(org_str, import_str, 7)) {
287+
obj = MP_OBJ_NULL;
288+
}
289+
284290
// look for matches
285291
size_t match_len;
286292
qstr q_first, q_last;
@@ -291,19 +297,12 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
291297
if (q_first == 0) {
292298
// If there're no better alternatives, and if it's first word
293299
// in the line, try to complete "import".
294-
static const char import_str[] = "import ";
295300
if (s_start == org_str && s_len > 0) {
296301
if (memcmp(s_start, import_str, s_len) == 0) {
297302
*compl_str = import_str + s_len;
298303
return sizeof(import_str) - 1 - s_len;
299304
}
300305
}
301-
// after "import", suggest built-in modules
302-
if (len >= 7 && !memcmp(org_str, import_str, 7)) {
303-
obj = MP_OBJ_NULL;
304-
match_str = find_completions(
305-
s_start, s_len, obj, &match_len, &q_first, &q_last);
306-
}
307306
if (q_first == 0) {
308307
*compl_str = " ";
309308
return s_len ? 0 : 4;

0 commit comments

Comments
 (0)