-
Notifications
You must be signed in to change notification settings - Fork 81
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
Fix range formatting #1190
Fix range formatting #1190
Conversation
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.
Generally LGTM and works very nicely. I've left a few comments inline.
After the last changes, this case stopped working:
Input: function printx(x)
println("x = $x")
return
end Output: function printx(x)
println("x = $x")
return
endend Since now we are only replacing the text inside the given range, it is more difficult to test because we cannot specify how the entire file has to look after formatting (see c05eaa7). This case is not caught by any of the tests because the returned formatted text is correct. However, it is misplaced in the input file. Any idea how we could make these tests more robust? I will look into why this case fails later this week. |
Where does the extra |
The original one is not copied over, so we end up with two of them. We are probably making a wrong assumption about the presence of a newline char at the end of the given range. I noticed that if you add an empty line at the end of the file, then it works fine. |
What do you mean with copied over? Sounds like a mismatch in how you mark what is going to be formatted then? The |
I mean that the |
I mean that since you insert regular line comments you must mark full lines to format, and then you must also replace the full line, not the original range, right? |
Yes.
we need to replace the introduced marks (comments) and all the lines inside the range. We use this regex to do that:
|
And this is the other part that we modified: which could also be the source of the problem. I don't have the laptop configured to debug LS.jl at the moment. I'll post an update as soon as I can test this a bit more. |
I'm sorry. This was all noise. The range formatting is working fine. I think I accidentally typed the undo button and disregarded the fix made here a765897. 😳 |
Yea I couldn't reproduce. I played around a bit with the PR, is it OK if I push some changes to hopefully make it more resilient towards different lineendings? |
Please do so! |
them to support the whole suite of 1.x Julia versions
Co-authored-by: Sebastian Pfitzner <[email protected]> Co-authored-by: Fredrik Ekre <[email protected]>
This reverts commit e01e292.
When there is an empty line at the end of the code, the format selection operation will be performed. There will be the following error: |
Fixed by #1228? |
Fixes #1180, #1187, #1188, and probably #1184
Here is the idea:
This approach avoids the need of having to deal with EXPRs and formats the given range in the context of the entire file.