Open PullJosh opened 1 month ago
Might be a little tricky to make sure the cursor sticks effectively where it was - so it doesn't shift somewhere a bit offset when you save - but this is presumably something other IDEs have already figured out, and maybe something prettier itself supports?
Yes indeed! https://prettier.io/docs/en/api.html#prettierformatwithcursorsource--options
formatWithCursor
both formats the code, and translates a cursor position from unformatted code to formatted code. This is useful for editor integrations, to prevent the cursor from moving when code is formatted.
I think this should be a very strong default (possibly even the only option for now). Particularly for beginners, opinionated code formatting helps a lot.