-
-
Notifications
You must be signed in to change notification settings - Fork 7
fix: map functions without closing brace mapping #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| diff --git a/CHANGELOG.md b/CHANGELOG.md | ||
| deleted file mode 100644 | ||
| index dad8c06aac26cb8cfced31da5f35ac8e95915f15..0000000000000000000000000000000000000000 | ||
| diff --git a/lib/get-mapping.js b/lib/get-mapping.js | ||
| index 187a02ed65104d8e3a058d6bfe7dc8bd7c285369..10dbf17549a6a0795e868bbc2ea6d0df661da514 100644 | ||
| --- a/lib/get-mapping.js | ||
| +++ b/lib/get-mapping.js | ||
| @@ -36,13 +36,26 @@ function originalEndPositionFor(sourceMap, generatedEnd) { | ||
| // generated file end location. Note however that this position on its | ||
| // own is not useful because it is the position of the _start_ of the range | ||
| // on the original file, and we want the _end_ of the range. | ||
| - const beforeEndMapping = originalPositionTryBoth( | ||
| + let beforeEndMapping = originalPositionTryBoth( | ||
| sourceMap, | ||
| generatedEnd.line, | ||
| generatedEnd.column - 1 | ||
| ); | ||
| if (beforeEndMapping.source === null) { | ||
| - return null; | ||
| + for ( | ||
| + let line = generatedEnd.line; | ||
| + line > 0 && beforeEndMapping.source === null; | ||
| + line-- | ||
| + ) { | ||
| + beforeEndMapping = originalPositionTryBoth( | ||
| + sourceMap, | ||
| + line, | ||
| + Number.MAX_SAFE_INTEGER | ||
| + ); | ||
| + } | ||
| + if (beforeEndMapping.source === null) { | ||
| + return null; | ||
| + } | ||
| } | ||
|
|
||
| // Convert that original position back to a generated one, with a bump |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,9 @@ test("svelte for loop", async ({ actual, expected }) => { | |
| expect(actual).toMatchInlineSnapshot(` | ||
| { | ||
| "branches": "0/0 (100%)", | ||
| "functions": "0/3 (0%)", | ||
| "functions": "0/4 (0%)", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to vue,
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "lines": "0/3 (0%)", | ||
| "statements": "0/5 (0%)", | ||
| "statements": "0/6 (0%)", | ||
| } | ||
| `); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,9 @@ test("vue for loop", async ({ actual, expected }) => { | |
| expect(actual).toMatchInlineSnapshot(` | ||
| { | ||
| "branches": "0/0 (100%)", | ||
| "functions": "0/0 (100%)", | ||
| "lines": "0/2 (0%)", | ||
| "statements": "0/2 (0%)", | ||
| "functions": "0/1 (0%)", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "lines": "0/3 (0%)", | ||
| "statements": "0/3 (0%)", | ||
| } | ||
| `); | ||
|
|
||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this patch temporarily to make the test pass.