-
Notifications
You must be signed in to change notification settings - Fork 72
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
Using color code moves cursor to the right #24
Comments
If you're using a local copy of That solved it for me. + import ansiRegex from "ansi-regex";
/**
* Advances the `offset` as required in order to accompany the prompt
* additions to the input.
*/
applyPromptOffset(input, offset) {
const newInput = this.applyPrompts(input.substr(0, offset));
- return newInput.length;
+ return newInput.replace(ansiRegex(), "").length;
} You'll have to install |
Thank you! In addition to the change above, I also updated export function countLines(input, maxCols) {
- return offsetToColRow(input, input.length, maxCols).row + 1;
+ return offsetToColRow(input, input.replace(ansiRegex(), "").length, maxCols).row + 1;
} |
let row = 0,
col = 0;
+input = input.replace(ansiRegex(), '');
for (let i = 0; i < offset; ++i) { |
If you use for example
\u001b[32m
to colorize you prompt the cursor will be moved to the right (by the count of the hidden chars) if you have entered at least one character:The text was updated successfully, but these errors were encountered: