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

Erroneous truncated columns when using colSpan #289

Closed
speedytwenty opened this issue Apr 4, 2022 · 0 comments · Fixed by #290
Closed

Erroneous truncated columns when using colSpan #289

speedytwenty opened this issue Apr 4, 2022 · 0 comments · Fixed by #290
Labels
bug Something isn't working

Comments

@speedytwenty
Copy link
Collaborator

If an entire column contains cells with a colWidth > 1, they don't get a proper width calculation (when colWidths aren't specified).

This can occur in different circumstances.

const Table = require('.');

const table = new Table({ debug: 3 });
table.push([{ colSpan: 2, content: 'I should not be truncated' }]);
console.log(table.toString());

Expected:

┌────────────────────────────┐
│ I should not be truncated  │
└────────────────────────────┘

Current behavior:

┌───┐
│ … │
└───┘

If a cell above has colSpan, no width is passed down, and a cell below might be truncated when it doesn't need to be. Eg.

const Table = require('.');
const table = new Table();
table.push(
  [{ content: '0-0 (1x3)', colSpan: 3, rowSpan: 1 }],
  [
    { content: '1-0 (2x2)', colSpan: 2, rowSpan: 2 },
    { content: '1-2 (2x1)', colSpan: 1, rowSpan: 2 },
  ],
  []
);
console.log(table.toString());

Expected:

┌────────────────────────┐
│ 0-0 (1x3)              │
├────────────┬───────────┤
│ 1-0 (2x2)  │ 1-2 (2x1) │
│            │           │
│            │           │
└────────────┴───────────┘

Current behavior:

┌───────────────┐
│ 0-0 (1x3)     │
├───┬───────────┤
│ … │ 1-2 (2x1) │
│   │           │
│   │           │
└───┴───────────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant