linenoise icon indicating copy to clipboard operation
linenoise copied to clipboard

Rewrote the calculation of prompt length, ignoring length of ANSI esc…

Open GreaTdANie1 opened this issue 5 years ago • 2 comments

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: before

After: after

GreaTdANie1 avatar Feb 27 '20 09:02 GreaTdANie1

Hi, thanks for the PR. In general it looks like a good idea. May I ask why you are using strpbrk instead of strchr?

antirez avatar Feb 27 '20 09:02 antirez

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.

GreaTdANie1 avatar Feb 27 '20 09:02 GreaTdANie1