linenoise
linenoise copied to clipboard
Bug fix when the prompt contains ESC chars
refreshSingleLine would use strlen to count the number of "forward" operations to send to the cursor. This causes the cursor to move too far off if the prompt contains ANSI color codes. Example:
"\x1b[1mHello> \x1b[0m" contains 15 characters, but only 7 on rendered on the terminal, so refreshSingleLine would move the cursor forward too much.
The function strlenPerceived counts the number of non escaped characters which appears to fix this bug.
Merged https://github.com/rain-1/linenoise/commit/0e3cf08cbbad0884861a1509ac6f7001ceeee2e3