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
The following error can be produced by setting wrapWord on a column that only contains empty cells.
1) drawTable
should not break when wrapWord is set on a column with empty cells:
SyntaxError: Invalid regular expression: /(^.{1,0}(\s+|$))|(^.{1,-1}(\\|/|_|\.|,|;|-))/: numbers out of order in {} quantifier
at new RegExp (<anonymous>)
at calculateStringLengths (src/wrapWord.ts:10:14)
at Object.wrapWord (src/wrapWord.ts:41:3)
at Object.wrapCell (src/wrapCell.ts:27:20)
at Object.calculateCellHeight (src/calculateCellHeight.ts:9:10)
at /Users/sebinsua/dev/table/src/calculateRowHeights.ts:17:26
at Array.forEach (<anonymous>)
at /Users/sebinsua/dev/table/src/calculateRowHeights.ts:16:9
at Array.map (<anonymous>)
at Object.calculateRowHeights (src/calculateRowHeights.ts:13:15)
at Object.table (src/table.ts:44:22)
at Context.<anonymous> (test/table.ts:29:7)
at processImmediate (node:internal/timers:464:21)
A test to show this:
describe("drawTable",()=>{it("should not break when wrapWord is set on a column with empty cells",()=>{constconfig: TableUserConfig={columnDefault: {wrapWord: true,},};expect(table([["this",""],["breaks",""],["badly",""],],config)).to.be.deep.equal(`╔════════╤══╗║ this │ ║╟────────┼──╢║ breaks │ ║╟────────┼──╢║ badly │ ║╚════════╧══╝`.trimLeft());});});
The error message appears to come from this function:
The following error can be produced by setting
wrapWord
on a column that only contains empty cells.A test to show this:
The error message appears to come from this function:
table/src/wrapWord.ts
Lines 4 to 35 in 0553391
I haven't spent a lot of time with this codebase but could we
Math.max
the right side of the quantifier so it's at least as large as the left-side?e.g.
Or does it make sense to immediately bail while returning an empty list of chunks?
If you're happy with either of these fixes, or have your own suggestion, I can send you a PR.
The text was updated successfully, but these errors were encountered: