Skip to content

--cursor-offset output is wrong sometimes #1981

@josephfrazier

Description

@josephfrazier

I just wanted to note that since the cursorOffset option (introduced in #1637) works by tracking the cursor position relative to an AST node (rather than a CST token), it can produce incorrect results. For example:

$ echo "return         15" | prettier --cursor-offset 15 # the cursor is positioned immediately before `15`
return 15;
15

(related to prettier/prettier-vscode#12 (comment))

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions