From 1ebf9483d46397d4548f5d614adb28956b37a23e Mon Sep 17 00:00:00 2001 From: indirectlylit Date: Mon, 16 May 2016 17:24:45 -0700 Subject: [PATCH 1/5] pad results with whitespace - re #190 --- lib/parser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index de7f533fd..c5d83b9a1 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -109,6 +109,9 @@ module.exports = function (content, filename, needMap) { } else { lineOffset = content.slice(0, start).split(splitRE).length - 1 result = deindent(content.slice(start, end)) + + // pad whith whitespace so that error messages are correct + result = Array(lineOffset+1).join("\n") + result; } if (needMap) { @@ -128,7 +131,7 @@ module.exports = function (content, filename, needMap) { map.addMapping({ source: filenameWithHash, original: { - line: index + 1 + lineOffset, + line: index + 1, column: 0 }, generated: { From 63cd024b4c3466f07a13ba55c4c456a510be40b4 Mon Sep 17 00:00:00 2001 From: indirectlylit Date: Mon, 16 May 2016 20:50:23 -0700 Subject: [PATCH 2/5] address linter issues --- lib/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index c5d83b9a1..cbe81c46a 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -111,7 +111,7 @@ module.exports = function (content, filename, needMap) { result = deindent(content.slice(start, end)) // pad whith whitespace so that error messages are correct - result = Array(lineOffset+1).join("\n") + result; + result = Array(lineOffset + 1).join('\n') + result } if (needMap) { From 2a32451452cc1c94bfaaf919865576d1a98c0e3e Mon Sep 17 00:00:00 2001 From: indirectlylit Date: Tue, 17 May 2016 12:48:57 -0700 Subject: [PATCH 3/5] fix failing test --- test/test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 959ab05d5..7663a8024 100644 --- a/test/test.js +++ b/test/test.js @@ -215,7 +215,8 @@ describe('vue-loader', function () { }), function (err) { expect(err).to.be.null getFile('test.output.css', function (data) { - expect(data).to.contain('h1 {\n color: #f00;\n}\n\nh2 {\n color: green;\n}') + console.log(data); + expect(data).to.contain('h1 {\n color: #f00;\n}\n\n\n\n\n\n\nh2 {\n color: green;\n}') done() }) }) From 2bc55ef8236ff80e03a66a0ef871231262217edc Mon Sep 17 00:00:00 2001 From: indirectlylit Date: Wed, 25 May 2016 09:00:31 -0700 Subject: [PATCH 4/5] remove debug log --- test/test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test.js b/test/test.js index 7663a8024..038dc6c04 100644 --- a/test/test.js +++ b/test/test.js @@ -215,7 +215,6 @@ describe('vue-loader', function () { }), function (err) { expect(err).to.be.null getFile('test.output.css', function (data) { - console.log(data); expect(data).to.contain('h1 {\n color: #f00;\n}\n\n\n\n\n\n\nh2 {\n color: green;\n}') done() }) From e52c84f437a748bf341f7616d42a0efaeb1dd5da Mon Sep 17 00:00:00 2001 From: indirectlylit Date: Wed, 25 May 2016 09:02:09 -0700 Subject: [PATCH 5/5] move var definition inside else block --- lib/parser.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/parser.js b/lib/parser.js index cbe81c46a..a353635d1 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -97,9 +97,7 @@ module.exports = function (content, filename, needMap) { var start = node.childNodes[0].__location.startOffset var end = node.childNodes[node.childNodes.length - 1].__location.endOffset var result - var lineOffset if (type === 'script') { - lineOffset = 0 // preserve other parts as commenets so that linters // and babel can output correct line numbers in warnings result = @@ -107,7 +105,7 @@ module.exports = function (content, filename, needMap) { deindent(content.slice(start, end)) + commentScript(content.slice(end), lang) } else { - lineOffset = content.slice(0, start).split(splitRE).length - 1 + var lineOffset = content.slice(0, start).split(splitRE).length - 1 result = deindent(content.slice(start, end)) // pad whith whitespace so that error messages are correct