ManuelHentschel / VSCode-R-Debugger

R Debugger Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=RDebugger.r-debugger
MIT License
170 stars 11 forks source link

Enhancement when set a break point at blank line #148

Open xiajunwen1007 opened 3 years ago

xiajunwen1007 commented 3 years ago

Describe the enhancement When I set a breakpoint at the line with no command, the R debugger would automatically run the following lines with commands. For example, set a breakpoint at the blank line before K=1 with the following code. A gif will be posted to show this.

fo <- function(x){
    x + K
}

bar <- function(x,y){
    fo(x + y)
}

K=1
print(bar(1, 2))

屏幕录制2021-08-08 下午1 32 42

ManuelHentschel commented 3 years ago

Thanks for raising this issue.

To an extent, this is intended, since stopping at an empty line might be a bit confusing (since nothing would happen if you click "Step Over (F10)").

Apparently, the python extension handles this by moving the breakpoint to the previous (non-empty) line. Something like this should be possible here. Is this the behaviour you would expect?

Also, note that a breakpoint always pauses the execution before running the specified line of code, so in your example you could safely set the breakpoint in line 9.

xiajunwen1007 commented 3 years ago

Rstudio handles this by moving the breakpoint to the next (non-empty) line. I prefer this as well. But it is ok to follow the python extension.