eric pouech (@epo) commented about programs/cmd/wcmdmain.c:
/* Calculate cursor position at beginning of prompt, accounting for lines scrolled* due to length of input.*/GetConsoleScreenBufferInfo(hOutput, ¤tConsoleInfo);currentConsoleInfo.dwCursorPosition.X = startConsoleInfo.dwCursorPosition.X;len2 -= (currentConsoleInfo.dwSize.X - currentConsoleInfo.dwCursorPosition.X);if (len2 > 0) {currentConsoleInfo.dwCursorPosition.Y -= ((len2 / currentConsoleInfo.dwSize.X) + 1);}SetConsoleCursorPosition(hOutput, currentConsoleInfo.dwCursorPosition);WriteConsoleW(hOutput, inputBuffer, len, &numWritten, NULL);if (maxLen > len) {clear_console_characters(hOutput, maxLen - len, lastConsoleInfo.dwSize.X); /* width at time of last console update */}
and likely you could do 'maxLen = len;' here: as screen is "cleared" after 'len' position, there's no need to clear it again (unless a wider string is needed, but you'll catch that later)