-
Notifications
You must be signed in to change notification settings - Fork 44
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
Renaming a module adds additional new lines #159
Comments
@karthiknadig I'm unable to reproduce in Neovim with |
This is what i get as a response message:
As you can see in the response there is additional |
@pappasam I am seeing more reports of this. microsoft/vscode-python#17024 |
@karthiknadig I'll try adding the test case in a bit to see if I can narrow it down. |
tl;dr I cannot reproduce this issue with the example provided. @karthiknadig I've added some automated tests with your example. They pass on both Ubuntu and Windows containers with Github actions. Here's the relevant commit: f2c7a5e If this is indeed an issue with the latest version of |
I just found a fix (for me anyway) for this issue. Perhaps it could also shed light on what could be happening behind the scenes. I usually use Linux, but I sometimes develop on Windows and this issue seemed to only happen on Windows in my case. The issue seems to be with the carriage return character. If you switch the line ends in your file for LF (\n) instead of CRLF (\r), the issue stops happening. To change default character used when pressing enter in VSCode, you can follow this guide. Hope this helps, cause this definitely plagued me. |
@karthiknadig is this issue still present with the latest release? I've tried testing this out in several ways on my machine by running files through unix2dos, which adds carriage returns locally, and I've so-far been unable to reproduce on my end. |
I will investigate this one. If there is anything, i will make a PR. But it might take some time for me to get to this. |
@pappasam I investigated the issue, I think it is coming from lsp_text_edits:
The which is forcing the extra line. The new code line ending should probably be cleaned up to look like old code line endings. |
Yep, that's the function that I've been examining for a long time and haven't been able to figure out exactly why this is happening. As we've discussed earlier, this seems like a pretty deep, VSCode Windows-specific issue. If I'm reading your example correctly, the original version of the code does not actually have carriage returns and @Quoding seems to have a technique that fixes this issue in VSCode: #159 (comment) @karthiknadig Two questions for you:
|
@pappasam I don't think defining such a setting would be a good idea here. The issue actually occurs because, how both of these contents are acquired. In I think we should try and see if we can update |
@pappasam I verified that updating this line |
I am still experiencing this issue, whereby renaming a symbol in one function inserts new lines throughout the module. |
Me too. I am still experiencing this issue, whereby renaming a symbol in one function inserts new lines throughout the module. |
I'm not 100% sure it's relevant but I've come across a line endings bug in Pygls where it wasn't taking into consideration I have a PR ready openlawlibrary/pygls#304 I was hoping for a bit more feedback before merging. Is anybody here in a position to test to see if it fixes the issue? |
For me, this was only happening on Windows. As a workaround, I simply changed the line endings for the current file from CRLF to LF. This can be done by selecting the "CRLF" item in the bottom status bar, then choose LF from the popup menu. If doing this causes other issues (like with git), you can then change it back to CRLF after you have done the rename operation. |
Still happening, and LF->CRLF workaround not working. |
Before:
After:
Looks like the refactor code adds new lines, to each change.
The text was updated successfully, but these errors were encountered: