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

Fix wrapping bug on lists #255

Closed
wants to merge 3 commits into from

Conversation

adriancooney
Copy link

This should fix the issue #214 where wrapping lines caused extra lines to be added to the prompt. The problem was where the lines wrapped and it caused the screens count of lines to clear to fall out of sync. I'm not exactly sure how to unit test this but from manual tests, it seems to work fine. Another potential bug is when the terminal resizes, it will go out of sync because it only updates the line count on render so that will need to be accounted for in future.

Behaviour differences

Here is a demonstration of the behaviour differences introduced by this PR:

var lines = content.split(/\n/);
this.height = lines.length;
var lines = content.split(/\n/),
width = cliWidth();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use one var statement per line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, fixed!

@adriancooney
Copy link
Author

Actually, there's an issue with this. It counts hidden characters such as color and incorrectly assumes the length of the line. Actual length of the line needs to be detected either by rendering then counting or somehow flattening colors and text decoration.

@SBoudrias
Copy link
Owner

Yeah, you can use strip-ansi for that. I have a branch on the side that's doing a very similar logic. Another issue with your implementation is that it won't consider the cursor position if you're outsetting it with a long line. Also, I'm pretty sure it'll break our input prompts where the user answer is wrapping.

So this is not mergeable as is, but I might base something out of your solution.

@adriancooney
Copy link
Author

That's cool! Glad I could help somehow. Any rough ETA on a fix?
On Tue 30 Jun 2015 at 00:45, Simon Boudrias notifications@github.com
wrote:

Yeah, you can use strip-ansi for that. I have a branch on the side that's
doing a very similar logic. Another issue with your implementation is that
it won't consider the cursor position if you're outsetting it with a long
line. Also, I'm pretty sure it'll break our input prompts where the user
answer is wrapping.

So this is not mergeable as is, but I might base something out of your
solution.


Reply to this email directly or view it on GitHub
#255 (comment)
.

@SBoudrias
Copy link
Owner

My fix is on master now.

@SBoudrias SBoudrias closed this Jul 4, 2015
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.

2 participants