Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GreaTdANie1
Copy link

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

@antirez
Copy link
Owner

antirez commented Feb 27, 2020

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

@GreaTdANie1
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants