Skip to content

Erroneous truncated columns when using colSpan #289

Closed

Description

@speedytwenty

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions