It does this by refactoring the "serial close" code from multiple places into a single function.
By leaving the content of the terminal when closing the serial it might look like the REPL is still running, which it isn't after a serial reconnection.
In this GIF you can see me opening the REPL, execute a command, and then trying to go back and press the UP key in the keyboard to try to repeat the last command.
Every time the UP key is pressed we can see an error in the console (different issue), and it isn't until Ctrl+C is pressed that the REPL is running again.
I think this also possibly fixes the issue that was reported by some users where typing in the terminal would print on the screen the same character multiple times.
It does this by refactoring the "serial close" code from multiple places into a single function.
By leaving the content of the terminal when closing the serial it might look like the REPL is still running, which it isn't after a serial reconnection.
In this GIF you can see me opening the REPL, execute a command, and then trying to go back and press the UP key in the keyboard to try to repeat the last command. Every time the UP key is pressed we can see an error in the console (different issue), and it isn't until Ctrl+C is pressed that the REPL is running again.
I think this also possibly fixes the issue that was reported by some users where typing in the terminal would print on the screen the same character multiple times.