mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 22:02:59 -07:00
fix(ui): clamped table column widths (#26991)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -265,6 +265,24 @@ describe('TableRenderer', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('handles extremely small terminal widths without crashing', async () => {
|
||||
const headers = ['Col 1', 'Col 2'];
|
||||
const rows = [['Data 1', 'Data 2']];
|
||||
// This width is much smaller than the overhead, which could lead to negative column widths
|
||||
const terminalWidth = 1;
|
||||
|
||||
const renderResult = await renderWithProviders(
|
||||
<TableRenderer
|
||||
headers={headers}
|
||||
rows={rows}
|
||||
terminalWidth={terminalWidth}
|
||||
/>,
|
||||
);
|
||||
const { unmount } = renderResult;
|
||||
// If it didn't throw RangeError: Invalid count value, the test passes
|
||||
unmount();
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: 'handles non-ASCII characters (emojis and Asian scripts) correctly',
|
||||
|
||||
@@ -250,7 +250,9 @@ export const TableRenderer: React.FC<TableRendererProps> = ({
|
||||
};
|
||||
|
||||
const char = chars[type];
|
||||
const borderParts = adjustedWidths.map((w) => char.horizontal.repeat(w));
|
||||
const borderParts = adjustedWidths.map((w) =>
|
||||
char.horizontal.repeat(Math.max(0, w || 0)),
|
||||
);
|
||||
const border = char.left + borderParts.join(char.middle) + char.right;
|
||||
|
||||
return <Text color={theme.border.default}>{border}</Text>;
|
||||
|
||||
Reference in New Issue
Block a user