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

Validation message cut off at the last character. #126

Closed
henzeb opened this issue Mar 17, 2024 · 4 comments
Closed

Validation message cut off at the last character. #126

henzeb opened this issue Mar 17, 2024 · 4 comments

Comments

@henzeb
Copy link

henzeb commented Mar 17, 2024

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
Copy link
Member

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
Copy link
Author

henzeb commented Mar 17, 2024

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
Copy link
Member

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
Copy link
Author

henzeb commented Mar 18, 2024

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

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

No branches or pull requests

2 participants