Skip to content

Commit 909210e

Browse files
authored
Merge pull request #1850 from katlings/filter-underscores
Filter private methods from tab completion
2 parents 6e842aa + eb3cb4d commit 909210e

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

py/repl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
187187
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
188188
mp_load_method_protected(obj, q, dest, true);
189189
if (dest[0] != MP_OBJ_NULL) {
190+
// special case; filter out words that begin with underscore
191+
// unless there's already a partial match
192+
if (s_len == 0 && d_str[0] == '_') {
193+
continue;
194+
}
190195
if (match_str == NULL) {
191196
match_str = d_str;
192197
match_len = d_len;

tests/cmdline/repl_autocomplete.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
1, x.isdi ()
77
i = str
88
i.lowe ('ABC')
9+
x = 5
10+
x. 
11+
x._
912
None. 

tests/cmdline/repl_autocomplete.py.exp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@ Use \.\+
1010
>>> i = str
1111
>>> i.lower('ABC')
1212
'abc'
13+
>>> x = 5
14+
>>> x.
15+
from_bytes to_bytes
16+
>>> x.
17+
>>> x.__class__
18+
<class 'int'>
1319
>>> None.
1420
>>>

tests/unix/extra_coverage.py.exp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ RuntimeError:
2727
# repl
2828
ame__
2929

30-
__class__ __name__ argv byteorder
31-
exc_info exit getsizeof implementation
32-
maxsize modules path platform
33-
print_exception stderr stdin
34-
stdout version version_info
30+
argv byteorder exc_info exit
31+
getsizeof implementation maxsize modules
32+
path platform print_exception
33+
stderr stdin stdout version
34+
version_info
3535
ementation
3636
# attrtuple
3737
(start=1, stop=2, step=3)

0 commit comments

Comments
 (0)