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

Pressing return in PHPStorm terminal (macOS) doesn't work #66

Closed
davidwdan opened this issue Dec 18, 2017 · 13 comments · Fixed by #73 or #79
Closed

Pressing return in PHPStorm terminal (macOS) doesn't work #66

davidwdan opened this issue Dec 18, 2017 · 13 comments · Fixed by #73 or #79
Labels
Milestone

Comments

@davidwdan
Copy link

macOS uses \r instead of \n for return.

https://github.com/clue/php-stdio-react/blob/master/src/Readline.php#L47

@clue
Copy link
Owner

clue commented Dec 18, 2017

Thanks for reporting @davidwdan. What kind of system are you using, what kind of error are you seeing and how can this be reproduced?

I don't have a Mac to test against, but it's my understanding that only legacy "Mac OS Classic" used CR instead of LF?

Can anybody else confirm these issues?

@davidwdan
Copy link
Author

There isn't an error, it just doesn't recognize the return keypress. If I add "\r" => 'onKeyEnter', everything works as expected.

I did a little more testing and this is only an issue if I'm using the terminal with PHPStorm.

@clue
Copy link
Owner

clue commented Dec 18, 2017

Thanks for confirming back! This is indeed an interesting find if PHPStorm's terminal only uses CR instead of LF or CRLF here.

Can you try running the examples and see how they behave? Also, does this affect only the latest v1.2.0 version or can you also test this against a later version? What is the value of PHP_EOL?

Now that #65 is in (for upcoming v2.0.0 though), I wonder what should be emitted for the data event here. Linux and recent Macs use line\n, Windows (not currently supported, see #18) would emit line\r\n and legacy Mac OS Classic would use line\r. Considering this is working on a stream, I suppose the latter may be difficult to distinguish from a possible line\r\n.

@davidwdan davidwdan changed the title Pressing return on macOS doesn't work Pressing return in PHPStorm terminal (macOS) doesn't work Dec 18, 2017
@davidwdan
Copy link
Author

The demos work in v1.0.0 and v1.1.0 but not v1.2.0 or dev-master.

PHP_EOL is \n

@clue
Copy link
Owner

clue commented Jan 24, 2018

Ping @davidwdan, what is the status here? Can you give some instructions on how to reproduce this and/or if you've found a way to avoid / work around this?

I don't have a Mac to test against, can anybody else confirm that all examples are apparently broken on Mac?

@davidwdan
Copy link
Author

I haven't had a chance to look into this any more. I should have some time in the next couple of days.

@clue
Copy link
Owner

clue commented Mar 1, 2018

Closing this due to a lack of feedback, as we can not reproduce this. Please come back with more details if this problem persists and we can reopen this 👍

@clue clue closed this as completed Mar 1, 2018
@davidwdan
Copy link
Author

This is still an issue, I just haven't had time to look into it anymore.

@mkopinsky
Copy link

mkopinsky commented Jun 28, 2018

I'm experiencing this on MacOS with the QuickStart example. If I hit Ctrl-J it reads my input, but Enter or Ctrl-M do not submit. This applies regardless of the terminal (I used stock MacOS Terminal as well as iTerm), and regardless of any .bash_profile settings (I ran bash with env -i bash --norc --noprofile as recommended at https://stackoverflow.com/a/21391035/299313). I believe PHP_EOL is '\n' , based on the output below.

$ php -r "echo 'testing'.PHP_EOL;"|file -
/dev/stdin: ASCII text

As @davidwdan found, changing Readline.php to say "\r" => 'onKeyEnter', does fix this behavior for me. Changing it to PHP_EOL => 'onKeyEnter', does not fix it. Weird.

@clue
Copy link
Owner

clue commented Jun 28, 2018

@mkopinsky Thank you for confirming this issue!

@clue clue reopened this Jun 28, 2018
@clue
Copy link
Owner

clue commented Jun 28, 2018

Can you check if your PHP installation includes ext-readline (see php -m)? Also, can you try patching the source by commenting out

if (function_exists('readline_callback_handler_install')) {
// Prefer `ext-readline` to install dummy handler to turn on raw input mode.
// We will nevery actually feed the readline handler and instead
// handle all input in our `Readline` implementation.
readline_callback_handler_install('', function () { });
return $stream;
}
and seeing if this changes anything about this?

@mkopinsky
Copy link

Yes, ext-readline is installed.

Commenting out those lines fixed the issue - Enter, Ctrl-J, and Ctrl-M are all interpreted as ending the line.

@clue
Copy link
Owner

clue commented Sep 1, 2018

For the reference: I've just reverted #73 via #80 now that #79 addresses the underlying issues. This means that ext-readline will now be used again on all platforms that support it, including Mac OS X.

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