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

HighLine.new.ask("Q?"){|q| q.overwrite = true} errors with version 1.6.5 #17

Closed
astounding opened this issue Nov 11, 2011 · 5 comments
Closed

Comments

@astounding
Copy link

Running gem version 1.6.5 under Ruby 1.9.2 I encounter this:

require 'highline'
answer = HighLine.new.ask("Password:"){|q| q.overwrite = true ; q.echo = '*'}

Result:
Password:
**********You must enter a valid HighLine::String.

The code worked just fine in previous versions, returning the user's input. If I omit the q.overwrite=true part, it works. So something has changed in the overwrite code path that breaks HighLine.

Thanks.

Aaron Gifford

@astounding
Copy link
Author

It looks like the issue occurs within get_response after the while loop gathers the input here:

    if @question.overwrite
      @output.print("\r#{ERASE_LINE}")
      @output.flush
    else
      say("\n")
    end

Something's going on with ERASE_LINE it seems that is causing execution of get_response to abort and for ask's line:
@answer = @question.answer_or_default(get_response)
to be called immediately again, thus calling get_response again, after outputting the message, "You must enter a valid HighLine::String."

Aaron out.

@astounding
Copy link
Author

Ah, it appears the ERASE_LINE constant is missing. I can't find it anywhere. That would definitely be a problem.

@astounding
Copy link
Author

Verified. Whenever highline.rb attempts to reference ERASE_LINE, exception "uninitialized constant Object::ERASE_LINE" is being raised.

@astounding
Copy link
Author

For now so HighLine would work for me, I just replaced ERASE_LINE with HighLine.Style('erase_line').code in two places. And once again it works for me.

@astounding
Copy link
Author

Closing this issue as issue 18 (pull request) has one possible solution to this bug (and refers back to this issue).

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

No branches or pull requests

1 participant