posit-dev / positron

Positron, a next-generation data science IDE
Other
1.59k stars 43 forks source link

Ark: `View()` should support function objects #2945

Open DavisVaughan opened 2 months ago

DavisVaughan commented 2 months ago

So you can look at their sources in a temporary editor pane, ideally recognized as an R file with syntax highlighting

lionel- commented 2 months ago

In Positron I think it makes sense for this functionality to be fulfilled by F12, i.e. jump-to-definition. And if we do implement View() for functions, it would be nice if it worked exactly the same way as F12? I.e. follow source references if any, create virtual doc otherwise.

Cf "Generalised source availability" section of https://github.com/posit-dev/positron/issues/408

EllaKaye commented 1 week ago

I'd love to see View(function-name) work as @DavisVaughan suggested. I really like this feature in RStudio and it's one thing I miss in Positron so far. Would the F12/jump-to-definition proposal work for base R functions? At the moment, if I press F12 on the name of a base R function in Positron, I see No reference found for 'function-name'.

lionel- commented 1 week ago

Would the F12/jump-to-definition proposal work for base R functions?

yep, currently needs more infrastructure to implement it but you can already get a feel of how it'd work by running this in the console:

debugonce(data.frame)
data.frame()

This will drop you in the debugger (jump-to-def wouldn't). You can type Q in the console to quit it.

EllaKaye commented 1 week ago

Thanks. That would be neat. I would still find it really handy to have a way of pulling that up from the R console as well, either with View() or with F12.