From dfc20889d67974d812b0c8c6a6451ab995ce3cfd Mon Sep 17 00:00:00 2001 From: Hannu Pelkonen Date: Tue, 16 Jun 2015 11:18:25 +0300 Subject: [PATCH] Fix: Ignored blocks should not change line numbering --- lib/modules/ignore-block.js | 6 +++++- test/unit/modules/ignore-block.test.js | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/modules/ignore-block.js b/lib/modules/ignore-block.js index 62255fc4..b81df40f 100644 --- a/lib/modules/ignore-block.js +++ b/lib/modules/ignore-block.js @@ -5,10 +5,14 @@ function removeIgnoredBlocks(string) { ignoreEnabled = false; lines.forEach(function(line) { if (line.indexOf('styleguide:ignore:start') !== -1) { + results.push(''); ignoreEnabled = true; } else if (line.indexOf('styleguide:ignore:end') !== -1) { + results.push(''); ignoreEnabled = false; - } else if (!ignoreEnabled) { + } else if (ignoreEnabled) { + results.push(''); + } else { results.push(line); } }); diff --git a/test/unit/modules/ignore-block.test.js b/test/unit/modules/ignore-block.test.js index d6b1df5d..20d19ca5 100644 --- a/test/unit/modules/ignore-block.test.js +++ b/test/unit/modules/ignore-block.test.js @@ -18,7 +18,7 @@ styleguide:ignore:end Last line */ }); - expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nLast line'); + expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line'); }); it('should remove everything on the same line as tags', function() { @@ -32,7 +32,7 @@ Ignore 2 Last line */ }); - expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nLast line'); + expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line'); }); it('should support multiple blocks', function() { @@ -49,7 +49,7 @@ styleguide:ignore:end Last line */ }); - expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nMiddle line\nLast line'); + expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\nMiddle line\n\n\n\nLast line'); }); it('should remove everything after start tag even if it is not closed', function() { @@ -62,6 +62,6 @@ Ignore 2 Ignore 3 */ }); - expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line'); + expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n'); }); });