Open guillaumebrunerie opened 7 months ago
I believe it can be fixed with the following patch (it is indeed the a0
which is not handled properly).
diff --git a/apheleia-rcs.el b/apheleia-rcs.el
index e462921..3d73181 100644
--- a/apheleia-rcs.el
+++ b/apheleia-rcs.el
@@ -100,7 +100,7 @@ contains the patch."
;; Account for the off-by-one error in the RCS patch spec
;; (namely, text is added *after* the line mentioned in
;; the patch).
- (when (eq (alist-get 'command command) 'addition)
+ (when (and (eq (alist-get 'command command) 'addition) (> (alist-get 'start command) 0))
(forward-line))
(push `(marker . ,(point-marker)) command)
(push command commands)
I’m not sure how to run the tests to make sure it doesn’t break anything else, running make fmt-build FORMATTERS=prettier-javascript
fails with the error
build-image.bash: tagging apheleia-formatters:latest
build-image.bash: will install all formatters by default
test/formatters/build-image.bash: line 30: args[@]: unbound variable
I suspect the script is being run in Zsh, no idea why or how to make it run in Bash instead. Not sure anymore, running the script directly with Bash makes no difference. I’m on Mac OS Sonoma if it matters.
Consider the following file in a Javascript project with Prettier and the plugin https://github.com/IanVS/prettier-plugin-sort-imports (which makes Prettier automatically sort imports):
Formatting it in Emacs with Apheleia results in the following invalid code:
(the expected behavior is that
fourthImport
is moved to the first line).Running
apheleia-npx
from the terminal with the correct arguments correctly formats the file, so the issue seems to be in Apheleia, not in the formatter. Here is the RCS diff I get, runningdiff
in the terminal with the same arguments as Apheleia):Could it be that the
a0
line isn’t handled correctly?