linenoise icon indicating copy to clipboard operation
linenoise copied to clipboard

Bug fix when the prompt contains ESC chars

Open olegat opened this issue 8 years ago • 1 comments

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.

olegat avatar Feb 28 '17 12:02 olegat

Merged https://github.com/rain-1/linenoise/commit/0e3cf08cbbad0884861a1509ac6f7001ceeee2e3

rain-1 avatar May 15 '18 17:05 rain-1