Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Tui] Should InputWidget handle prompts wider than the available columns? #64525

Copy link
Copy link
@rcsofttech85

Description

@rcsofttech85
Issue body actions

Symfony version(s) affected

8.1

Description

InputWidget can currently return a line wider than the available render columns when its prompt alone is wider than the RenderContext.

In that case, InputWidget::render() computes a non-positive $availableColumns, but returns the prompt unchanged:

if ($availableColumns <= 0) {
    return [$prompt];
}

### How to reproduce


**How To Reproduce**

```md
```php
use Symfony\Component\Tui\Render\RenderContext;
use Symfony\Component\Tui\Render\Renderer;
use Symfony\Component\Tui\Widget\InputWidget;

$input = new InputWidget();
$input->setPrompt('This prompt is too long: ');
$input->setValue('hidden');

(new Renderer())->renderWidget($input, new RenderContext(10, 24));

### Possible Solution

When the prompt is wider than the available render width, `InputWidget` should still honor the widget render contract and return a line whose visible width does not exceed `RenderContext::getColumns()`.

Since `InputWidget` is a single-line widget, wrapping the prompt is not appropriate. The prompt can be clipped/truncated to the available column width in this edge case.

One possible fix is to replace:

```php
if ($availableColumns <= 0) {
    return [$prompt];
}
with
if ($availableColumns <= 0) {
    return [AnsiUtils::truncateToWidth($prompt, $columns, '', true)];
}

### Additional Context

_No response_
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.