Correctly format files and ranges with line endings other than LF#28
Correctly format files and ranges with line endings other than LF#28ccordoba12 merged 3 commits intopython-lsp:masterfrom
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. |
| import black | ||
| import toml | ||
| from pylsp import hookimpl | ||
| from pylsp._utils import get_eol_chars |
There was a problem hiding this comment.
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.
You're right. We inherited that from the old Palantir project and now it's used everywhere in our fork.
|
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.