-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix Code.Fragment.surround_context for keyword keys #13843
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
Conversation
ed9c88e
to
88c7fc6
Compare
lib/elixir/lib/code/fragment.ex
Outdated
@@ -656,6 +665,9 @@ defmodule Code.Fragment do | |||
{{:dot, _, [_ | _]} = dot, offset} -> | |||
build_surround(dot, reversed, line, offset) | |||
|
|||
{{:local_or_var, acc}, offset} when keyword? -> | |||
build_surround({:keyword, acc}, reversed, line, offset) |
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 don't think keyword
should be returned here. It's already used for reserved words do end after else catch rescue fn true false nil
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.
Got it, I misunderstood what keyword
meant in this context.
keyword_atom
/ keyword_key
?
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.
Macro.inspect_atom
uses key
. Maybe that's fine? Or we use atom_key
or keyword_key
.
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'm fine with both.
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.
Either sounds good, I went with :key
for the consistency.
Last question: in the case of do:
, should it be a :key
or a :keyword
?
It would be :key
with the current PR implementation, but I'm not sure which would make sense from a LSP perspective @lukaszsamson
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.
do:
should be :key
IMO.
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.
It's OK, let's have do:
as key
and do
as keyword
.
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.
Great, thanks gents will merge as is then 🚀
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 just realized: should we call out this "edge case" in the docs?
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 don't think it is an edge case, honestly. It is how the grammar behaves everywhere. :) So there is no need imo!
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.
Except for the name, LGTM!
Related to part 1. of #13818