mirror of
https://github.com/micropython/micropython.git
synced 2025-08-15 23:20:35 +02:00
py/repl: Filter private methods from tab completion.
Anything beginning with "_" will now only be tab-completed if there is already a partial match for such an entry. In other words, entering foo.<tab> will no longer complete/list anything beginning with "_". Originally at adafruit#1850 Signed-off-by: Kathryn Lingel <kathryn@lingel.net>
This commit is contained in:
committed by
Damien George
parent
aa061ae391
commit
1f1a54d0b1
@@ -197,6 +197,11 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
|
|||||||
for (qstr q = MP_QSTR_ + 1; q < nqstr; ++q) {
|
for (qstr q = MP_QSTR_ + 1; q < nqstr; ++q) {
|
||||||
size_t d_len;
|
size_t d_len;
|
||||||
const char *d_str = (const char *)qstr_data(q, &d_len);
|
const char *d_str = (const char *)qstr_data(q, &d_len);
|
||||||
|
// 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 (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
|
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
|
||||||
mp_load_method_protected(obj, q, dest, true);
|
mp_load_method_protected(obj, q, dest, true);
|
||||||
if (dest[0] != MP_OBJ_NULL) {
|
if (dest[0] != MP_OBJ_NULL) {
|
||||||
|
@@ -28,11 +28,11 @@ RuntimeError:
|
|||||||
# repl
|
# repl
|
||||||
ame__
|
ame__
|
||||||
|
|
||||||
__class__ __name__ argv atexit
|
argv atexit byteorder exc_info
|
||||||
byteorder exc_info exit getsizeof
|
exit getsizeof implementation maxsize
|
||||||
implementation maxsize modules path
|
modules path platform print_exception
|
||||||
platform print_exception stderr
|
stderr stdin stdout version
|
||||||
stdin stdout version version_info
|
version_info
|
||||||
ementation
|
ementation
|
||||||
# attrtuple
|
# attrtuple
|
||||||
(start=1, stop=2, step=3)
|
(start=1, stop=2, step=3)
|
||||||
|
Reference in New Issue
Block a user