fix misaligned line numbers in sourcemaps ()

pull/4746/head
nomnomnomnom 5 years ago committed by GitHub
parent e3fef0f740
commit cf72b41575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,7 +37,8 @@ export default function read_script(parser: Parser, start: number, attributes: N
message: `<script> must have a closing tag`
});
const source = ' '.repeat(script_start) + parser.template.slice(script_start, script_end);
const source = parser.template.slice(0, script_start).replace(/[^\n]/g, ' ') +
parser.template.slice(script_start, script_end);
parser.index = script_end + script_closing_tag.length;
let ast: Program;

@ -0,0 +1,9 @@
<!--
Multiline
comment
-->
<script>
function assertThisLine() {}
</script>
{foo.bar.baz}

@ -0,0 +1,16 @@
export function test({ assert, smc, locateInSource, locateInGenerated }) {
const expected = locateInSource( 'assertThisLine' );
const start = locateInGenerated( 'assertThisLine' );
const actual = smc.originalPositionFor({
line: start.line + 1,
column: start.column
});
assert.deepEqual( actual, {
source: 'input.svelte',
name: null,
line: expected.line + 1,
column: expected.column
});
}

@ -0,0 +1,9 @@
<script context="module">
export let first;
</script>
<script>
function assertThisLine() {}
</script>
{foo.bar.baz}

@ -0,0 +1,16 @@
export function test({ assert, smc, locateInSource, locateInGenerated }) {
const expected = locateInSource( 'assertThisLine' );
const start = locateInGenerated( 'assertThisLine' );
const actual = smc.originalPositionFor({
line: start.line + 1,
column: start.column
});
assert.deepEqual( actual, {
source: 'input.svelte',
name: null,
line: expected.line + 1,
column: expected.column
});
}
Loading…
Cancel
Save