Skip to content

Commit

Permalink
fix: mergeWhitespaceTokens offset calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 1, 2024
1 parent 94dbc8a commit 3cf46d5
Show file tree
Hide file tree
Showing 34 changed files with 641 additions and 6,612 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/code-to-hast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function mergeWhitespaceTokens(tokens: ThemedToken[][]) {
if (couldMerge) {
newLine.push({
...token,
offset: firstOffset,
content: carryOnContent + token.content,
})
}
Expand All @@ -209,6 +210,7 @@ function mergeWhitespaceTokens(tokens: ThemedToken[][]) {
token,
)
}
firstOffset = 0
carryOnContent = ''
}
else {
Expand Down
1 change: 0 additions & 1 deletion packages/twoslash/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export function createTransformerFactory(
lang = langAlias[this.options.lang]

if (filter(lang, code, this.options)) {
this.options.mergeWhitespaces = 'never'
const twoslash = twoslasher(code, lang, twoslashOptions)
this.meta.twoslash = twoslash
this.options.lang = twoslash.meta.extension || lang
Expand Down
2 changes: 1 addition & 1 deletion packages/twoslash/test/out/classic/compiler_errors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/twoslash/test/out/classic/completions.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/twoslash/test/out/classic/simple.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3cf46d5

Please sign in to comment.