summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2019-05-08 13:47:29 -0400
committerGitHub <noreply@github.com>2019-05-08 13:47:29 -0400
commit909210e00dbc758584f75aaf302b2269b62d2c80 (patch)
tree0154bb155f9ddfa7187bf891141076744f31d261
parent6e842aa66f4a546f69385c8d7ca55df7b69ccce7 (diff)
parenteb3cb4d99bc324d941e4fd32fd30c86ebf4c44e3 (diff)
Merge pull request #1850 from katlings/filter-underscores
Filter private methods from tab completion
-rw-r--r--py/repl.c5
-rw-r--r--tests/cmdline/repl_autocomplete.py3
-rw-r--r--tests/cmdline/repl_autocomplete.py.exp6
-rw-r--r--tests/unix/extra_coverage.py.exp10
4 files changed, 19 insertions, 5 deletions
diff --git a/py/repl.c b/py/repl.c
index da0fefb3a..699ef10a6 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -187,6 +187,11 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
mp_load_method_protected(obj, q, dest, true);
if (dest[0] != MP_OBJ_NULL) {
+ // special case; filter out words that begin with underscore
+ // unless there's already a partial match
+ if (s_len == 0 && d_str[0] == '_') {
+ continue;
+ }
if (match_str == NULL) {
match_str = d_str;
match_len = d_len;
diff --git a/tests/cmdline/repl_autocomplete.py b/tests/cmdline/repl_autocomplete.py
index 27cad428f..43c49cdc2 100644
--- a/tests/cmdline/repl_autocomplete.py
+++ b/tests/cmdline/repl_autocomplete.py
@@ -6,4 +6,7 @@ x = '123'
1, x.isdi ()
i = str
i.lowe ('ABC')
+x = 5
+x. 
+x._
None. 
diff --git a/tests/cmdline/repl_autocomplete.py.exp b/tests/cmdline/repl_autocomplete.py.exp
index 75002985e..7d160e7bf 100644
--- a/tests/cmdline/repl_autocomplete.py.exp
+++ b/tests/cmdline/repl_autocomplete.py.exp
@@ -10,5 +10,11 @@ Use \.\+
>>> i = str
>>> i.lower('ABC')
'abc'
+>>> x = 5
+>>> x.
+from_bytes to_bytes
+>>> x.
+>>> x.__class__
+<class 'int'>
>>> None.
>>>
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 9df852757..06b5d3790 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -27,11 +27,11 @@ RuntimeError:
# repl
ame__
-__class__ __name__ argv byteorder
-exc_info exit getsizeof implementation
-maxsize modules path platform
-print_exception stderr stdin
-stdout version version_info
+argv byteorder exc_info exit
+getsizeof implementation maxsize modules
+path platform print_exception
+stderr stdin stdout version
+version_info
ementation
# attrtuple
(start=1, stop=2, step=3)