-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Labels
area:rangesIssues about formatting/ignoring/etc segments of filesIssues about formatting/ignoring/etc segments of fileslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Environments:
- Prettier Version: 2.8.8
- Running Prettier via: Node.js API
- Runtime: Node.js 18.16.0
- Operating System: macOS
- Prettier plugins (if any):
Steps to reproduce:
Save this script and run it:
import prettier from "prettier";
const code = `
// All messages are represented in JSON.
// So, the prettierd.py controls a subprocess which spawns "node {this_file}".
import { } from "fs"
`; // ^ cursor here
console.log(
prettier.formatWithCursor(code, {
cursorOffset: 129,
parser: "babel",
})
); // => { cursorOffset: 65 }
Expected behavior:
Expect the returned cursorOffset
to be around 129, right in the {}
.
Actual behavior:
It returns 65, which is in the comments.
Frankly, I don't even find a minimal case to reproduce this issue (the code above is all I could make, changing any line of the comment may make the result correct).
Metadata
Metadata
Assignees
Labels
area:rangesIssues about formatting/ignoring/etc segments of filesIssues about formatting/ignoring/etc segments of fileslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.