apheleia
apheleia copied to clipboard
Point is sometimes moved small distances
Example:
if (node.type === "CallExpression" && (node.callee.type === "Import" || (node.callee.type === "Identifier" && node.callee.name === "require"))) {
//@
}
with point represented by @
is reformatted by Prettier to:
if (
node.type === "CallExpression" &&
(node.callee.type === "Import" ||
(node.callee.type === "Identifier" && node.callee.name === "require"))
) {@
//
}
instead of:
if (
node.type === "CallExpression" &&
(node.callee.type === "Import" ||
(node.callee.type === "Identifier" && node.callee.name === "require"))
) {
//@
}
I suspect that this problem could be solved by tweaking the weights used in the dynamic programming algorithm.
I was having that pointer moving out of place problem and seems like I was able to fix it by setting the --line-length
in apheleia to 78. What's weird is that the only thing I have I have using 78 is the warning-fill-column
variable which doesn't seem like it can be related, so not sure.
(setf (alist-get 'black apheleia-formatters)
'("black" "--line-length" "78" "-"))
But does seem like Black/Emacs format-conflicts can lead to these types of issues.
I think this is unlikely to be directly related to the line length configuration. I think what you're observing is just that the diff being applied is slightly different, which happens to trigger the (somewhat nondeterministic) limitation in Apheleia's dynamic programming algorithm that is the cause of point moving.
This is fixed now #290 is merged.