cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.15k stars 81 forks source link

Filter instances to only include matches that have same scope type as input #2066

Open pokey opened 1 year ago

pokey commented 1 year ago

We already do this when we detect that the input for "instance" is a token or word, but we should do it for other scopes. We should also construct a target of the right scope type. For example:

const aaa = bbb(ccc, ddd);
const eee = ccc + ddd(ccc, fff);

In this case, "chuck two instances arg cap" should give:

const aaa = bbb(ddd);
const eee = ccc + ddd(fff);

Note how:

I do wonder if this behaviour would be surprising? Would you see that ccc in const ccc as an instance of the same thing?

Related:

Approach

pokey commented 12 months ago

Another potential problem here: this behaviour will likely be quite surprising with "name". If I say "clear every instance name" as a poor-man's rename, it wouldn't work, because the other instances won't be names 🤔

I am starting to get the feeling that "name", "first token", etc should downgrade to "token" for inference / instance, as they are most often the problem children for this kinda thing. They're often just used as a convenient way to target a token, rather than a semantically rich scope. Idk

Cc/ @josharian

josharian commented 12 months ago

I think the best way to answer that question is to play around with it a bit.

pokey commented 12 months ago

Which question?

josharian commented 12 months ago

Whether some scopes should be downgraded to token.

pokey commented 12 months ago

Right yeah I think that makes sense. On the first question of whether requiring "name" to be "name" for instance, I'm quite confident that would bite me

pokey commented 10 months ago

Update from meet-up: