-
-
Notifications
You must be signed in to change notification settings - Fork 247
Fix alignment issue involving margin comments. #609
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 alignment issue involving margin comments. #609
Conversation
Alignment wasn't working properly when nested, multi-line sexps were followed by margin comments.
0ed7ba2
to
51d6b48
Compare
@@ -705,6 +705,11 @@ x | |||
"#?@(:clj [2] | |||
:cljs [2])") | |||
|
|||
(when-aligning-it "should work correctly when margin comments appear after multi-line, non-terminal sexps" | |||
"(let [:x (+ 2 3 |
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.
This seems an odd example, I really don't recall ever seeing an aligned function invocation.
Hashmaps, case
s, etc are more frequent targets.
Also, this piece of code would look exactly the same for the aligned and not aligned cases, so one can't really tell if you're affecting alignment at all with the proposed changes.
I'd suggest choosing a variety of examples, and also, add ; comment
s at different positions, to get really good coverage.
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 think alignment of let
bindings is common. I made the strange decision to use keywords for the left-hand side of the bindings, which I will definitely update.
I will update to add examples for hashmap
and case
. I plan to still use a single test with a single form, but I will add all three cases within the form. I think that's what you have in mind.
I will also update so that the alignment isn't trivial; I can see how that might be confusing, but I also what to make clear that it is besides the point. The point is that when you align code that is already aligned correctly, it is getting mangled (see the attached issue). This test does fail if you undo the regexp change I made.
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.
Thanks! Appreciated.
Simply for record, I still don't see a particular alignment in the example, neither for the let
itself or the function invocations:
I'm aware that let
alignment is a thing but it's better shown e.g. here:
...Just in case, indentation != alignment.
btw, this initial newline I added in both of my examples would make the tests more readable. I think it would be welcome if you can update all examples to include it.
(I haven't tried running the tests like that, might require removing the initial newline programatically if present)
Alright, updated. A couple notes:
|
Looks all good to me! Great work. As one last suggestion, you could add examples with I cannot further review these days for personal reasons, someone else will have to approve/merge |
I'll take it from here. |
I wasn't sure if I was meant to test margin comments that begin |
Actually, I suppose having one test with a variety of different comment examples makes sense. I guess I just have tunnel vision for the specific bug I am fixing. I can combine the two tests into one that covers all examples if that style is preferred. |
More test coverage is usually a good thing, plus some conventions are not as strong with Clojure as with older Lisps - e.g. a lot of people use |
Alignment wasn't working properly when nested, multi-line sexps were followed by margin comments.
Begin multi-line example strings with a newline so that the indentation of the first line in relation to the rest of the string is plain to see.
453a7ba
to
baa5469
Compare
Alright, I think I'm done then. I squashed my commits. |
Hi, just dropping a reminder that I am finished making changes with this PR and I think it's ready. Please let me know if there are any further changes desired. |
Thanks! |
Released as 5.14.0 |
Alignment wasn't working properly when nested, multi-line sexps were followed by margin comments.
M-x checkdoc
and fixed any warnings in the code you've written.Thanks!