laravel / prompts

Beautiful and user-friendly forms for your command-line PHP applications.
https://laravel.com/docs/prompts
MIT License
532 stars 94 forks source link

Validation message cut off at the last character. #126

Closed henzeb closed 8 months ago

henzeb commented 8 months ago

Laravel Prompts Version

0.1.16

Laravel Version

0

PHP Version

8.2

Operating System & Version

Kubuntu 22.04

Terminal Application

Konsole, Yakuake

Description

See below. Any message below the box is cut off.

Screenshot_20240317_134950

Steps To Reproduce

just create a test prompt in a script where composers autoload is loaded:

text('email', validate: function () {
    return 'Invalid emailaddress';
});

Just press enter.

I have not added a laravel version, but it is broken there as well.

jessarcher commented 8 months ago

Hi @henzeb,

I'm unable to replicate this using Konsole on Fedora:

image

I also don't see how it would be possible for this library to be the cause of this as terminals don't provide that level of control.

Can you try a different font and see if that might be causing it?

henzeb commented 8 months ago

The default font is named Hack. Changing the font does have some effect. But it changes the overall appearance and most is just making things look ugly. Adding a space at the end of the message also seems to fix it. (hence it doesn't look ugly when you use a period at the end of the line)

what's the font Fedora is using for Konsole?

jessarcher commented 8 months ago

what's the font Fedora is using for Konsole?

The default is set to "Monospace", which I assume just resolves to the system monospace default. I'm using Gnome, so I'm not sure what default it's using.

I just installed Hack from https://sourcefoundry.org/hack/ and configured it in Konsole, but still can't replicate the issue:

image

I also tried it with JetBrains Mono:

image

I suspect this is an issue with font rendering on your system. Prompts has little control over the rendering other than specifying characters and basic styling of things like colours.

In your screenshot, the warning symbol (Unicode U+26A0) looks like it's rendering wider than a single monospace character. That may be throwing off the way that your terminal calculates the width of the line, causing the cropping.

You could try replicating this by running the following commands:

echo "⚠ Invalid email address"
echo "Invalid email address"

There's also the possibility that the colours trigger some weird behaviour, so you might like to try including them too:

echo "\e[33m⚠ Invalid email address"
echo "\e[33mInvalid email address"

I will close this for now, as I don't think it's an issue with Prompts. Feel free to re-open if you can confirm that Prompts is specifically causing it. We could look at removing the warning symbol if it's triggering terminal bugs, but I'd want to see widespread reports before going that far.

henzeb commented 8 months ago

It is indeed the symbol. But we don't have to remove it. A simple space or newline character would be a good workaround.