-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add option to Document.source
to read files without universalized line endings.
#224
Comments
I think I'm seeing this issue too. But I don't completely understand the issue. Are you saying that forcing of UTF-8 in |
I may not understand this issue but in my opinion encoding does not play the role here. I encounterred this issue time ago and I had to change line endings in source file to finish operation without adding extra lines and change line endings back. It was during editing python source file in vscode. |
You had to change line endings in the source file? How do you mean? You, as an LSP user, had to change line endings in your editor, VSCode or Vim or something? That obviously is not the solution we're looking for here, because we want to be able to support all forms of line endings. |
OK. We are on the same boat. It is not a solution to change line endings for proper LSP functioning. To avoid confusion, here is video how LSP behaves with different line endings (utf-8 encoded source file): Code_0LCvZB7WmU.mp4 |
From Will open() function change line-endings in files? on python.org :
|
Fantastic, I see exactly what you mean now. Thank you. Also, I just read the Jedi server issue and there @karthiknadig suggested adding def source(self) -> str:
if self._source is None:
with io.open(self.path, 'r', encoding='utf-8', newline='') as f:
return f.read()
return self._source Could this be a potential fix? |
Currently
pygls
provides the text documentsource
where the line endings are universalized. This is an issue when computing diffs and while applying changes. Universalized line endings might not be the right thing when reading source files.pygls/pygls/workspace.py
Lines 273 to 277 in bbf671f
This is an example of a problem, where we are trying to handle refactoring request, and it leads to adding too many line endings. pappasam/jedi-language-server#159 . We had a similar problem implementing formatting. Any scenario where text edits have to be handled this becomes an issue.
In the message where
pygls
gets the text from the Languange client, I see that the IDE preserves the line endings. See this trace fortextDocument/didOpen
where the server receives full text, line endings are as is.It would be helpful if we can control the line endings for source files
The text was updated successfully, but these errors were encountered: