-
Notifications
You must be signed in to change notification settings - Fork 14
Be willing to complete in the face of emptiness #772
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
base: bugfix/nearest-enclosing-node
Are you sure you want to change the base?
Conversation
8790f19
to
cc1fb06
Compare
// Consider when the user asks for completions with no existing | ||
// text-to-complete, such as at the R prompt in the Console, in an empty R | ||
// file, or on an empty line of a non-empty R file. | ||
// | ||
// Gesture-wise, a Positron user could do this with Ctrl + Space, which | ||
// invokes the command editor.action.triggerSuggest. | ||
// | ||
// The nominal completion node in these cases is just the root or 'Program' | ||
// node of the AST. In this case, we should just provide "all" completions, | ||
// for some reasonable definition of "all". | ||
if x.node_type() == NodeType::Program { | ||
return true; | ||
} |
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 the idea in general, but I don't think this belongs in is_identifier_like()
, because the program node itself is not identifier-like.
I think at the call site it should be is_identifier_like(node) | is_empty_line(node)
and is_empty_line()
should contain this code.
The name is_empty_line
is a WIP, if you have anything better to call this, feel free to use that.
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.
Yes, this is a definitely an improvement on the expressive-ness front. I'll do it.
Fixes #770
Note that this layers on top of #805 which should be merged first. This PR currently targets that branch instead of
main
to make this clear.See the last "move" in #805 (comment) for a concrete illustration of what this PR does. If the client asks for completions in any context where we aren't inside a node (i.e. we're just in the 'Program' node), we should basically send all composite completions, instead of no completions.
I give this PR an A for correct behaviour and a C- for expressiveness. I really don't love that we're adding another special case to a free function named
is_identifier_like()
. It feels likeis_identifier_like()
is getting at some notion of "should we provide completions?" and this might be the time to articulate the intention more precisely. I suspect this property of the completion site could also become a peer ofparameter_hints_cell
andpipe_root_cell
, i.e. a feature we compute about the completion context early on and then use where needed.I would add a test before I merge this, but am holding off until after further discussion.