-
Notifications
You must be signed in to change notification settings - Fork 28
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
Completion for Active Record .where queries #526
base: main
Are you sure you want to change the base?
Conversation
This may also help: Shopify/ruby-lsp#2913 |
Planning on finishing and hopefully shipping this PR during hackdays next week! |
0b09971
to
896ba66
Compare
7077b8b
to
44cbede
Compare
44cbede
to
def281a
Compare
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 is great. Left some style comments
if arguments | ||
indexed_call_node_args = index_call_node_args(arguments: arguments) | ||
return if indexed_call_node_args.values.any? { |v| v == node } | ||
end |
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.
What is this early return checking for exactly? Is it that we're not processing arguments inside a nested call inside of the where
?
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 early return is meant to prevent suggestions when the user is typing in an argument value within a .where
in general. E.g when the user is typing User.where(id: creat
they shouldn't receive a column name suggestion for created_at
.
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.
Covered in this test case here
Closes: #369
Adding ActiveRecord
.where
completion suggestions.I've chosen to only provide suggestions once the user begins typing the name of the column to filter by. This is slightly different than the spec in the ticket. I don't think the call_node_enter listener can be used if suggestions are to be provided before the user begins typing a column name.
Happy to investigate this further! But I think this can be added as a follow up in another PR since the approach for when to begin suggesting seems like it should be different.
Here are some videos of how this looks!
vscode-demo.mov
neo-vim-demo.mov