Skip to content

Commit

Permalink
fix(widths): Line breaks in cell content are not taken into account w…
Browse files Browse the repository at this point in the history
…hen calculating the cell width
  • Loading branch information
ibmjanneme committed May 5, 2020
1 parent 6dac0cb commit 03928e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const getMaxLength = (columnOptions, rows, columnIndex) => {
if (row[columnIndex]) {
// check cell value is object or scalar
const value = (row[columnIndex].value) ? row[columnIndex].value : row[columnIndex]
const width = wcwidth(stripAnsi(value.toString()))
const width = Math.max(
...stripAnsi(value.toString()).split(/[\n\r]/).map((s) => wcwidth(s))
)
return (width > prev) ? width : prev
}
return prev
Expand Down

0 comments on commit 03928e3

Please sign in to comment.