You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
useSymfony\Component\Tui\Render\RenderContext;
useSymfony\Component\Tui\Render\Renderer;
useSymfony\Component\Tui\Widget\InputWidget;
$input = newInputWidget();
$input->setPrompt('This prompt is too long: ');
$input->setValue('hidden');
(newRenderer())->renderWidget($input, newRenderContext(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_
Symfony version(s) affected
8.1
Description
InputWidgetcan currently return a line wider than the available render columns when its prompt alone is wider than theRenderContext.In that case,
InputWidget::render()computes a non-positive$availableColumns, but returns the prompt unchanged: