jscheid / prettier.el

Prettier code formatting for Emacs.
GNU General Public License v3.0
167 stars 12 forks source link

Error when prettifying a region? #139

Open JordanAnthonyKing opened 2 weeks ago

JordanAnthonyKing commented 2 weeks ago

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

image

jscheid commented 2 weeks ago

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 commented 1 week ago

Whoops, reopening as a reminder to update the docs.