Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point is sometimes moved small distances #2

Closed
raxod502 opened this issue Jul 18, 2019 · 3 comments
Closed

Point is sometimes moved small distances #2

raxod502 opened this issue Jul 18, 2019 · 3 comments

Comments

@raxod502
Copy link
Member

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.

@jpablobr
Copy link

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.

@raxod502
Copy link
Member Author

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.

@raxod502
Copy link
Member Author

This is fixed now #290 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants