From 1d1a16d1da049414304b30f4fa0cf1cac53d72dc Mon Sep 17 00:00:00 2001 From: x0Lazarus <113273587+x0Lazarus@users.noreply.github.com> Date: Fri, 18 Sep 2026 09:33:04 -0700 Subject: [PATCH] Omit span junctions when row separators are disabled --- src/cell.js | 11 +++++++++++ test/issues/355-test.js | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/issues/355-test.js diff --git a/src/cell.js b/src/cell.js index d1fff67..3a3aa42 100644 --- a/src/cell.js +++ b/src/cell.js @@ -164,6 +164,17 @@ class Cell { * @returns {String} */ drawTop(drawRight) { + // Spanning cells can use top/bottom junctions for internal row separators. + // Do not let those junctions restore a separator that was explicitly hidden. + if ( + this.y > 0 && + this.chars.mid === '' && + this.chars.leftMid === '' && + this.chars.midMid === '' && + this.chars.rightMid === '' + ) { + return ''; + } let content = []; if (this.cells) { //TODO: cells should always exist - some tests don't fill it in though diff --git a/test/issues/355-test.js b/test/issues/355-test.js new file mode 100644 index 0000000..dd3102c --- /dev/null +++ b/test/issues/355-test.js @@ -0,0 +1,23 @@ +const Table = require('../..'); + +describe('empty row separators with column spans', () => { + const options = { + chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }, + colWidths: [5, 5], + style: { head: [], border: [] }, + }; + + test('does not draw a junction below a spanning cell', () => { + const table = new Table(options); + table.push([{ content: 'wide', colSpan: 2 }], ['one', 'two']); + + expect(table.toString()).toEqual(['┌───────────┐', '│ wide │', '│ one │ two │', '└─────┴─────┘'].join('\n')); + }); + + test('does not draw a junction above a spanning cell', () => { + const table = new Table(options); + table.push(['one', 'two'], [{ content: 'wide', colSpan: 2 }]); + + expect(table.toString()).toEqual(['┌─────┬─────┐', '│ one │ two │', '│ wide │', '└───────────┘'].join('\n')); + }); +});