prettier.el icon indicating copy to clipboard operation
prettier.el copied to clipboard

Error when prettifying a region?

Open JordanAnthonyKing opened this issue 1 year ago • 2 comments

I get errors when I simply try to prettify a highlighted region. Prettifying the enter buffer works without issue:

image

JordanAnthonyKing avatar Aug 29 '24 13:08 JordanAnthonyKing

From our docs:

M-x prettier-prettify-region to prettify region (but note that region should align with a complete block of code).

This is somewhat misleading, we should update the docs to read "a complete top-level block of code".

That's because we're sending only the selected block to Prettier and so it thinks it's formatting a top-level construct, which yours isn't.

Admittedly that's not very useful. Perhaps it would be better to send the whole buffer up to the end of the region, have Prettier format that, then throw away any changes outside the region. I might implement that in the successor to this project which I'm working on, on and off.

jscheid avatar Aug 29 '24 15:08 jscheid

Whoops, reopening as a reminder to update the docs.

jscheid avatar Sep 02 '24 15:09 jscheid