laravel / prompts

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

Usage of colors makes the right border position incorrect #45

Closed sc85 closed 1 year ago

sc85 commented 1 year ago

Laravel Prompts Version

0.1.14

Laravel Version

10.18.0

PHP Version

8.1.14

Operating System & Version

macOS 13.5

Terminal Application

Terminal

Description

When using a color within options the right border is not aligned but shifted to the left. So far, I noticed the issue with select, multiselect and search. This issue seems somehow similar to #29.

As visible in the screenshot the number of chars the border is shifted seems to be related to the number of chars used to identify the color.

image

P.S.: I love the new prompts 😍

Steps To Reproduce

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use function Laravel\Prompts\select;

class Dummy extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dummy';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Dummy command';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle(): int
    {
        select(
            'See the issue?',
            [
                'yes' => '<bg=green>yes</>',
                'no' => '<bg=red>no</>',
                'maybe' => '<bg=yellow>maybe</>',
                'dontKnow' => 'don\'t know',
            ],
        );
        return Command::SUCCESS;
    }
}
devajmeireles commented 1 year ago

Thanks to the report, @sc85 .

This PR fix this issue.

jessarcher commented 1 year ago

Thanks, @devajmeireles!