diff --git a/README.md b/README.md index 06d0f57fd..cfac4f2eb 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Bugs to fix: - Fix not resetting the shell when importing a file from command-line - Fix current working directory not changing during a module import (for relative imports) +- Fix accumulated events being processed when the program "ends" (if we can + detect that) Python features: - Compare features with existing implementations and other brands diff --git a/ports/sh/main.c b/ports/sh/main.c index d4776c00d..04ce943ab 100644 --- a/ports/sh/main.c +++ b/ports/sh/main.c @@ -113,13 +113,17 @@ static char *path_to_module(char const *path) interrupt MicroPython instead. */ static bool async_filter(key_event_t ev) { - if(mp_interrupt_char < 0) - return true; - if(ev.type == KEYEV_DOWN && ev.key == KEY_ACON) { - /* This function is designed to be called asynchronously. */ - mp_sched_keyboard_interrupt(); + /* Gobble all events related to AC/ON to make sure that the keyboard driver + treats them as handled. Otherwise, we'd run the risk of filling the + event queue (if the user doesn't read from it) thus preventing the + driver from handling AC/ON releases, which disables further presses. */ + if(mp_interrupt_char >= 0 && ev.key == KEY_ACON) { + /* This function supports asynchronous calls, by design. */ + if(ev.type == KEYEV_DOWN) + mp_sched_keyboard_interrupt(); return false; } + return true; }