summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2025-03-26 11:29:54 +1100
committerDamien George <damien@micropython.org>2025-06-19 17:23:42 +1000
commit09541b78963d6aff334b143c3247271a939d54fa (patch)
tree35ffaac19370f18a483e8b6ea5af8b34d84516c6 /py
parent8eb56369967382b6644fa56b98acbff2e77a66a3 (diff)
downloadmicropython-09541b78963d6aff334b143c3247271a939d54fa.tar.gz
micropython-09541b78963d6aff334b143c3247271a939d54fa.zip
py/repl: Skip private variables when printing tab completion options.HEADmaster
Any '_' variables/functions in frozen modules are currently printed, when they shouldn't be. That's due to underscore names possibly existing between the start and end qstrs which are used to print the auto-complete matches. The underscore names should be skipped when iterating between the two boundary qstrs. The underscore attributes are removed from the extra coverage exp file because tab completing "import <tab>" no longer lists modules beginning with an underscore. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Diffstat (limited to 'py')
-rw-r--r--py/repl.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/repl.c b/py/repl.c
index 87c171cc87..b0ccfa383a 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -218,6 +218,10 @@ static void print_completions(const mp_print_t *print,
for (qstr q = q_first; q <= q_last; ++q) {
size_t d_len;
const char *d_str = (const char *)qstr_data(q, &d_len);
+ // filter out words that begin with underscore unless there's already a partial match
+ if (s_len == 0 && d_str[0] == '_') {
+ continue;
+ }
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
if (test_qstr(obj, q)) {
int gap = (line_len + WORD_SLOT_LEN - 1) / WORD_SLOT_LEN * WORD_SLOT_LEN - line_len;