Repository navigation
Conversation
Vue condenses whitespace and decodes entities in node.content, and Svelte does the same in a Text node's data, so offsets taken from them miss the source. Measure the range on the raw source text and keep the decoded text as the message.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Member
Author
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "ad23c500715a9e9e03b38e2893fe19b0cf1de15c",
"result": {
"overallSummary": "The Vue and Svelte text scanners produced ranges from decoded/condensed text (`node.content`, `data`) instead of the raw source, so extraction replaced the wrong span and left a tail of original text behind. This PR measures the ranges on `node.loc.source` / `node.raw` while keeping the decoded text as the extracted message, and adds regression tests for indented, multi-line and entity text.",
"groups": [
{
"key": "scanner-source-ranges",
"label": "Source-based text ranges",
"summary": "Fix the range computation in both template scanners so offsets are taken from the untouched source text. The extracted message still uses the decoded text, so `text` and `range` intentionally no longer have the same length; the end offset is derived from the source's trimmed tail rather than from `text.length`.",
"category": "core",
"filePaths": [
"packages/builtins/src/scanners/vue/index.ts",
"packages/builtins/src/scanners/svelte/index.ts"
],
"critical": true,
"lineNotes": [
{
"path": "packages/builtins/src/scanners/vue/index.ts",
"side": "additions",
"line": 143,
"text": "`end` is now computed independently of `text`, so the range may be longer than the decoded `text` (entities like `&` expand). That is the point of the fix: the replacement span must cover the whole source token."
},
{
"path": "packages/builtins/src/scanners/svelte/index.ts",
"side": "additions",
"line": 45,
"text": "Leading whitespace offset comes from `raw`, while `text` is the decoded `data`; the two are deliberately mixed here. Inside the text, condensed whitespace is fine because only the outer trim offsets are used."
},
{
"path": "packages/builtins/src/scanners/svelte/index.ts",
"side": "additions",
"line": 105,
"text": "New `'raw' in node` guard: a Text node without a string `raw` is now skipped entirely instead of falling back to `data`-based offsets. Intended, but worth confirming no supported Svelte AST version omits `raw`."
}
]
},
{
"key": "tests",
"label": "Extraction regression tests",
"summary": "Two cases reproducing the bug: indented multi-line plus entity text in a `.vue` file, and an entity in a `.svelte` file. Both assert the rewritten source and the decoded message, so a range regression shows up as a leftover text tail.",
"category": "tests",
"filePaths": [
"packages/builtins/test/extract.test.ts"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-17T04:26:49.647Z",
"model": "openai-compatible/opencode-go/deepseek-v4.1-flash",
"locale": "en"
}
} |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #165
Description
The range for Vue template text came from
node.content, which condenses whitespace and decodes entities, so it no longer lines up with the source. The range is now measured onnode.loc.source, and the message stays the decoded text.Svelte had the same bug for entities: it measured on the decoded
datainstead of the Text node'sraw. Same fix there.Test
packages/builtins/test/extract.test.tshas two new cases. One extracts indented, multi-line and entity text from a.vuefile, and one extracts an entity from a.sveltefile. Both fail onmain, where the call replaces a short range and leaves a tail of the original text, and pass on this branch.