-
Notifications
You must be signed in to change notification settings - Fork 18
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
Correctly format files and ranges with line endings other than LF #28
Conversation
Thank you for the PR @ccordoba12, I will test it out as soon as I can, but I might not be able to do it until the weekend. My initial thought is that I would expect black to handle EOL itself. But maybe that only works when black opens the file itself, but we are passing raw input text instead. I would like to understand the internals better. I would also like to run some microbenchmarks for this code to make it as fast as possible, as it will be called all the time. The timeit module might be enough. |
Moving to 1.2.0 due to the urgency of releasing 1.1.0 given #29. |
25e5887
to
ac4e44f
Compare
Also drop support for Python 3.6 because that version of python-lsp-server only supports 3.7+
@haplo, this is ready for review. |
@@ -6,9 +6,11 @@ | |||
import black | |||
import toml | |||
from pylsp import hookimpl | |||
from pylsp._utils import get_eol_chars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish the module was pylsp.utils
and not _utils
, but not much we can do about that at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. We inherited that from the old Palantir project and now it's used everywhere in our fork.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🙌
Thanks @haplo for the review! Next week I'll work on the branch you created to add config options, so we can release 1.2.0 afterwards. |
black.format_file_contents
(the function we're using to format files and ranges) fails for CRLF and CR. So we need to convert line endings to LF before using it and restore them afterwards.