Skip to content

Provide completions in the "value" position #812

Open
@jennybc

Description

@jennybc

This is a variation / follow-up on #770.

We generally don't provide completions in the "value" position, in the sense of fn(name = value). This feels weird to me. It's admittedly a somewhat pedantic point, but I don't think it's pure pedantry. It feels like this violates the logic of how completions should work.

Pro tip: An explicit gesture to get completions is Ctrl/Cmd + Space. This works in some contexts where, say, pressing "tab" inserts a literal \t vs. triggering completions.

Consider this code:

a_kinda_long_name <- letters[1:3]
another_long_name <- letters[4:6]

append(x = a_kinda_long_name, y = another_long_name)

Below I indicate cursor position with @.

If you explicitly ask for completions at x = @, you get 'No suggestions'.

Image

But as soon as you type anything, e.g. x = a@, you get dozens of completions, including a_kinda_long_name and another_long_name.

Image

It feels like the implicit contract is that the completions for x = an@ are a subset of the completions for x = a@ are a subset of the completions for x =@. And we're currently violating that.

You can actually see that in this recording, where I request completions before I've typed anything, then get stuck in the land of 'No suggestions' until I backspace all the way back to the "=":

Screen.Recording.2025-05-22.at.2.29.56.PM.mov

The place to intervene is around here, but we don't yet have an easy way to add something that is morally is_value_position(node) to this condition:

if completion_context.document_context.node.is_program() ||
is_identifier_like(completion_context.document_context.node)

(Side note: I also noticie some duplication in the above completion lists 🤔. I have some ideas about that. But it's a separate matter, in any case.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions