Skip to content
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

Wrong cursorOffset with formatted JSX text #13986

Closed
Tracked by #78
Gregoor opened this issue Dec 13, 2022 · 0 comments · Fixed by #14163
Closed
Tracked by #78

Wrong cursorOffset with formatted JSX text #13986

Gregoor opened this issue Dec 13, 2022 · 0 comments · Fixed by #14163
Assignees
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@Gregoor
Copy link

Gregoor commented Dec 13, 2022

In a similar vein to #12491 (which I am still intending to fix), I found a misplaced cursorOffset issue with code like this

<>a•
  <div>hi</div>
</>

(where denotes the given cursor position)

When passed into prettier we get:

<>•
  a<div>hi</div>
</>

Which is unexpected, because the a correctly moves down, but the cursor stays up.

Here is code for testing it:

const prettier = require("prettier");
prettier.formatWithCursor(["<>a", "  <div>hi</div>", "</>"].join("\n"), { cursorOffset: 3, parser: 'babel' });

and the runkit to see it in the browser:
https://runkit.com/gregoor/prettier-jsx-cursor-offset-bug

@Gregoor Gregoor mentioned this issue Dec 13, 2022
2 tasks
@fisker fisker self-assigned this Jan 12, 2023
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants