linenoise
linenoise copied to clipboard
Rewrote the calculation of prompt length, ignoring length of ANSI esc…
Using strlen() to calculate the length of the prompt leads to mispositions of the cursor when the prompt passed in by users include ANSI escape codes (specifying prompt colors etc.). So I added a pstrlen() function to do the calculation of prompt, sort of solved the problem.
Before:

After:

Hi, thanks for the PR. In general it looks like a good idea. May I ask why you are using strpbrk instead of strchr?
Hi, thanks for the PR. In general it looks like a good idea. May I ask why you are using strpbrk instead of strchr?
Oh I didn't know the existence of strchr before this conversation lol. It is better indeed. strpbrk is a bit of a overkill.