diff --git a/src/UARTCommandHandler.cpp b/src/UARTCommandHandler.cpp index a4f75f0..9ad7f8f 100644 --- a/src/UARTCommandHandler.cpp +++ b/src/UARTCommandHandler.cpp @@ -55,15 +55,17 @@ void CommandLine::readInput() { // NOLINT(readability-function-cognitive-complex const char receivedChar = static_cast(UART->read()); if (isBackspace_(receivedChar)) { + lastWasCR_ = false; handleBackspace_(); } else if (isNewline_(receivedChar)) { - if (lastWasCR_){ - lastWasCR_ = false; // Handle \r\n by ignoring the \n + if (lastWasCR_ && receivedChar == '\n') { + lastWasCR_ = false; // Treat CRLF as a single newline event. continue; } lastWasCR_ = (receivedChar == '\r'); handleNewline_(); } else { + lastWasCR_ = false; handleChar_(receivedChar); } } @@ -170,4 +172,4 @@ void CommandLine::trimSpaces(std::string& str) { //NOLINT(readability-convert-me // If there are only spaces, clear the string str.clear(); } -} \ No newline at end of file +}