languageserver icon indicating copy to clipboard operation
languageserver copied to clipboard

How can I let workspace show variables inside a function() environment when in `browser()` mode.

Open milanglacier opened this issue 3 years ago • 0 comments
trafficstars

Hi!

I'm using M1 mac now, and currently the arm build has some bugs so vscdebugger cannot run. So now I have to resort to use the builtin debug functions like browser(), debug() to manually do debug in REPL using VSCode.

However, I find that while in browser() mode, the variables shown in the workspace window cannot be updated to the local environment with in the function call. even if I manually click the refresh button, the workspace do not update. Plus, the plots do not shown if the corresponding command is executed in browser() mode.

In contrast with RStudio, when browser() mode is on, the workspace window can show variables from different environment, for example, within a function call.

If tracking variables in different environment lively is a bit hard to be implemented, is there any way I can set a global variable to access variables in local environment and I can track it lively? (I don't want set the variables inside a function as a global variable, as it is generally not a good practice)

Thanks for your hardworking on this project and I would really appreciate it for any reply.


a = function(i) {

    browser()

    b = 0
    for(i in 1:5) {

        b = b + i

    }



}

a()
# ideally, I can track b in the workspace window

Updates:

I find that even I set b as a global variable, in browser() mode the workspace still cannot track the b, even I click the manual refresh button right to the workspace window.

a = function(i) {

    browser()

    b <<- 0
    for(i in 1:5) {

        b <<- b + i

    }

    # ideally, I can track b in the workspace window
}

a()

milanglacier avatar Jan 20 '22 22:01 milanglacier