posit-dev / positron

Positron, a next-generation data science IDE
Other
1.37k stars 42 forks source link

R: Select anonymous function snippet depending on context? #3649

Open lionel- opened 1 week ago

lionel- commented 1 week ago

When the fun snippet is expanded in argument position, it should not include the foo <- part:

https://github.com/posit-dev/positron/assets/4465050/1949445d-c3de-45ea-a108-ffb358bc4dd0

Not sure if that's possible but I'm hopeful since we moved the snippets to ark to gain more control over them depending on context: https://github.com/posit-dev/ark/pull/183

On a related note, variables is a strange term here. Should probably be changed to arg.

lionel- commented 1 week ago

Would also be nice to detect that user has already typed a name in: foo <- fun|

DavisVaughan commented 1 week ago

I'm pretty sure this is possible. The hart part is enumerating all the contexts where we don't want the name <-