-
Notifications
You must be signed in to change notification settings - Fork 8
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
Reproduce issue described in #45 - multi-byte characters are counted incorrectly. #53
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "failing-test-for-\u{1F4A9}"
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 |
---|---|---|
|
@@ -37,6 +37,37 @@ describe("parse", function () { | |
]); | ||
}); | ||
|
||
it("multi-byte characters", function () { | ||
let contentLength = "안녕하세요 세계".length; | ||
let openLength = "<template>".length; | ||
let closeLength = "</template>".length; | ||
let output = p.parse("<template>안녕하세요 세계</template>"); | ||
|
||
expect(output).to.eql([ | ||
{ | ||
type: "expression", | ||
tagName: "template", | ||
contents: "안녕하세요 세계", | ||
range: { | ||
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. a range is always |
||
start: 0, | ||
end: openLength + contentLength + closeLength, | ||
}, | ||
contentRange: { | ||
start: openLength, | ||
end: openLength + contentLength, | ||
}, | ||
startRange: { | ||
end: openLength, | ||
start: 0, | ||
}, | ||
endRange: { | ||
start: openLength + contentLength - 1, | ||
end: openLength + contentLength + closeLength, | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
it("expression position", function () { | ||
let output = p.parse("const tpl = <template>Hello!</template>"); | ||
|
||
|
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 defined all these lengths here because I can't count myself