Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't hit enter in text input #129

Closed
philharmonie opened this issue Apr 3, 2024 · 4 comments
Closed

Can't hit enter in text input #129

philharmonie opened this issue Apr 3, 2024 · 4 comments
Assignees

Comments

@philharmonie
Copy link

philharmonie commented Apr 3, 2024

Laravel Prompts Version

0.1.17

Laravel Version

10.48.4

PHP Version

8.2.16

Operating System & Version

macOS 14.2.1

Terminal Application

phpStorm 2023.3.35

Description

I can't hit enter to confirm a text input.
I already tried to rm -rf vendor && composer install && composer clear-cache && composer dump-autoload without success

Steps To Reproduce

Run e.g. artisan make:controller and enter the controller name.
When hitting enter, nothing happens.

@jessarcher
Copy link
Member

Hey @philharmonie, I don't have macOS or PhpStorm to test this, but I feel like this would have already come up before if it occurred in a typical configuration. I'm wondering whether there's a terminal setting that's changed how the Enter key is received in PHP.

To test this, could you please create a file (e.g. test.php) with the following contents:

<?php

$initialTtyMode = `stty -g`;

`stty -icanon -isig -echo`;

while ($keys = fread(STDIN, 1024)) {
    echo json_encode($keys).PHP_EOL;

    if ($keys === "\x03") {
        `stty $initialTtyMode`;

        exit(0);
    }
}

And then execute that file in the problematic terminal:

php test.php

It should echo out each key as you press it, so could you please press the Enter key and report the result? You can use Ctrl+C to exit when you're done.

Could you also please confirm whether or not this happens in another terminal application (e.g. the default macOS terminal or iTerm).

@jessarcher jessarcher self-assigned this Apr 4, 2024
@philharmonie
Copy link
Author

It prints \n and in the default macOS the issue does not occur. But in general the enter key is working in the phpStorm terminal.

@jessarcher
Copy link
Member

That's really strange. \n is the character we look for to detect an Enter keypress, so I can't think of any reason why Enter wouldn't be detected. The script I gave you emulates everything Prompts does to detect keypresses.

Can you confirm whether the issue occurs in a fresh Laravel installation?

@philharmonie
Copy link
Author

In the meantime there is a new update for phpstorm and the issue vanished. Still weird, but for me: resolved

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants