prettier / prettier-emacs

Minor mode to format JS code on file save

Home Page:http://jlongster.com/A-Prettier-Formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle cloned buffers and give error message when not visiting a file

michaeldickens opened this issue · comments

Currently, if I run prettier-js inside a cloned buffer (created by clone-indirect-buffer), prettier-js will fail with an unhelpful error message. Looks like the issue is that it determines where to run the prettier executable by calling buffer-file-name, but buffer-file-name is nil inside cloned buffers. It would be better to either find the base file by calling (buffer-file-name (buffer-base-buffer)) or at least print a more readable error message.

Relatedly, running prettier-js inside a buffer that's not visiting a file gives an unfriendly error message. prettier-js could check whether the buffer has a file and if not, raise a descriptive error message.

I wrote a PR to try to fix this issue: #76