-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Safer handling for
GetLineAndColumnForLocation
(#940)
* fix(#936): safer handling for GetLineAndColumnForLocation * chore: add changeset
- Loading branch information
1 parent
3909ab4
commit 9938bc1
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/compiler': patch | ||
--- | ||
|
||
Fixes a sourcemap-related crash when using multibyte characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
import { parse } from '@astrojs/compiler'; | ||
|
||
const FIXTURE = `{foo},`; | ||
|
||
test('does not crash', async () => { | ||
const result = await parse(FIXTURE); | ||
assert.ok(result.ast, 'does not crash'); | ||
}); | ||
|
||
test('properly maps the position', async () => { | ||
const { | ||
ast: { children }, | ||
} = await parse(FIXTURE); | ||
const text = children[1]; | ||
assert.equal(text.position.start.offset, 5, 'properly maps the text start position'); | ||
assert.equal(text.position.end.offset, 8, 'properly maps the text end position'); | ||
}); | ||
|
||
test.run(); |