positron icon indicating copy to clipboard operation
positron copied to clipboard

Ark: Can't use Cmd+Enter with fallback srcrefs because the virtual doc is a text file

Open lionel- opened this issue 1 year ago • 5 comments

When stepping through a function without srcrefs with the debugger, Ark creates fallback srcrefs on the fly that point to a virtual document. This document doesn't have a .R extension which reduces the functionality inside these files, for instance no colour styling. More importantly, this prevents executing code with Cmd+Enter. For instance, run the following and try to evaluate 1 +2 with Cmd+Enter:

foo <- function() {
  browser()
  1 + 2
}
foo()

You get this error:

Screenshot 2024-04-08 at 10 39 10

Davis mentioned this is because this fallback path is using the DAP to manage the virtual docs, and this isn't flexible enough to specify an extension. Maybe we could instead use a comment directive that we could detect in the frontend to set the correct language? Or manage the vdocs ourselves like we (will) do in https://github.com/posit-dev/amalthea/pull/251.

lionel- avatar Apr 08 '24 08:04 lionel-

You can't use CMD+Enter in the RStudio one either, I actually don't think that is that important to get right otherwise I would have complained to Kevin about it by now 😆

DavisVaughan avatar Apr 08 '24 15:04 DavisVaughan

I was surprised it didn't work in a real usage case.

lionel- avatar Apr 08 '24 15:04 lionel-

This issue was brought up in https://github.com/posit-dev/positron-beta/discussions/148

lionel- avatar Apr 29 '24 06:04 lionel-

Yea you have convinced me.

As discussed in slack and in other places, it is also with it to make it a "real" R file for highlighting purposes and probably other LSP features

DavisVaughan avatar Apr 29 '24 14:04 DavisVaughan

Likely need to merge https://github.com/posit-dev/amalthea/pull/251 first - that will probably actually make the situation a little better too

DavisVaughan avatar May 21 '24 14:05 DavisVaughan

Verified Fixed

Positron Version(s) : 2025.07.0-200
OS Version          : OSX

Test scenario(s)

Verified with steps outlined in https://github.com/posit-dev/ark/pull/852

Link(s) to TestRail test cases run or created:

testlabauto avatar Jun 26 '25 14:06 testlabauto