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

inputs repeating question when input wraps #214

Closed
callumacrae opened this issue Feb 4, 2015 · 24 comments
Closed

inputs repeating question when input wraps #214

callumacrae opened this issue Feb 4, 2015 · 24 comments
Labels

Comments

@callumacrae
Copy link

Sorry for the rubbish title, this is better explained by example.

screen shot 2015-02-04 at 16 19 58

If the input goes onto the next line, the question repeats for every character over the new line. It's a bit strange.

I'm using zprezto in iTerm2. Let me know if you need to know anything else.

@SBoudrias SBoudrias added the bug label Feb 4, 2015
@SBoudrias
Copy link
Owner

The prompt is re-rendered each time someone type a character, so my guess is once we have a line return the cleanup code for the previous line is not affecting a correct line.

A fix could be to compare the real line length to the terminal width and determine how many line we need to cleanup.

@callumacrae
Copy link
Author

Does seem to be what's happening: when the prompt becomes three lines long, the first two aren't touched.

I don't know how to write a test for this, sorry. Can you replicate it?

@jonschlinkert
Copy link

I've had the same issue on both windows and mac, in the built-in terminal on mac and iTerm.

@jviotti
Copy link

jviotti commented Apr 27, 2015

Are there plans to fix this?

@callumacrae
Copy link
Author

Heh, pasting tokens is the case I had, too

@jviotti
Copy link

jviotti commented Apr 27, 2015

I have a fix working locally. I'll submit a PR soon.

@callumacrae
Copy link
Author

👍 🎊

@jonschlinkert
Copy link

that would be great @jviotti. this happens every time I use yeoman

@jviotti
Copy link

jviotti commented Apr 27, 2015

PR sent: #239. I only tested on OS X, so if you run a different OS, your testing would be appreciated :)

FremyCompany added a commit to FremyCompany/Inquirer.js that referenced this issue May 21, 2015
I found out there was actually not good reason to to this
@FremyCompany
Copy link

FYI, I have a one-line fix (tested on Windows). Feel free to try it and comment on whether it works for you or not.

@callumacrae
Copy link
Author

Seems to be fixing the symptom of the problem and not the problem itself, though.

@FremyCompany
Copy link

Well if (like I assume) there's no reason to redraw the line on each keypress, then fixing the while-writing line-redrawing issue is a waste of time and adds more code to maintain than it should. In this case, it's easier to remove the behavior altogether. Also: it may work better when you resize your console than the previous fix (as the question & input text may or may not rewrap, making things hard to compute reliably).

But, you're right, the "redraw onEnd" is still buggy with this one-line fix. However, the amount of code required to fix that one bug would be much smaller than to fix both issues. Also, I don't care much about that remaining issue: what's important to me is that I can type more than one line without being disturbed ;-)

@FremyCompany
Copy link

Oh, by the way, this fixes another bug on Windows(cmder): the input cursor is now properly located at the insertion point, and not at the end of the input (#229).

It was really annoying to edit your text because you had to remember in your head where the insertion point was, and how many times you had to press LEFT or RIGHT to move to the right location. When you don't rewrite the text while Windows isn't looking, you don't have this problem.

@SBoudrias
Copy link
Owner

What happens when you submit the input and the validation fail?

@pauldijou
Copy link

I just wanted to highlight the fact that there is also a problem if the message of the question wraps. It gets really ugly with list and checkbox types because the message will be printed again and again and again each time the user navigate the answers using arrow keys. I do hope the PR also fix that...

screenshot from 2015-06-07 13 06 39

@adriancooney
Copy link

Also getting the same problem if a value in a list wraps.

@SBoudrias
Copy link
Owner

Fixed on master. Please test and let me know how it goes.

@jviotti
Copy link

jviotti commented Jul 6, 2015

@SBoudrias The repeating issue is fixed however:

  • When pasting a long line, the text prompt eats a bunch of lines from above.
  • When printing short new lines afterwards (console.log), there are parts of the token not being cleaned up at the right.

@SBoudrias
Copy link
Owner

@jviotti please open new issues for new issues :)

@allenGKC
Copy link

This problem happen when i npm install inquirer,anyone can help me?

@geyang
Copy link

geyang commented Jan 23, 2018

I'm seeing this problem again with long lines in checklist.

@SBoudrias
Copy link
Owner

@episodeyang please open a new issues with code and steps to reproduce the issues you're having.

@geyang
Copy link

geyang commented Jan 23, 2018 via email

@KID-joker
Copy link

KID-joker commented Apr 1, 2022

I just wanted to highlight the fact that there is also a problem if the message of the question wraps. It gets really ugly with list and checkbox types because the message will be printed again and again and again each time the user navigate the answers using arrow keys. I do hope the PR also fix that...

screenshot from 2015-06-07 13 06 39

@pauldijou I have the same problem. Did you solve it? The version is 8.2.1.

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

No branches or pull requests

10 participants