Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreliable readline prompt detection with active browser sessions #4742

Open
lionel- opened this issue Sep 19, 2024 · 0 comments
Open

Unreliable readline prompt detection with active browser sessions #4742

lionel- opened this issue Sep 19, 2024 · 0 comments
Labels
area: console Issues related to Console category. area: kernels Issues related to Jupyter kernels and LSP servers lang: r

Comments

@lionel-
Copy link
Contributor

lionel- commented Sep 19, 2024

When R requests inputs, we don't know for sure what is the intent:

  • The next top-level command to execute
  • The next command to execute in a debugging session
  • The last command was incomplete and R requests more input to complete it
  • Some running R code requests input via readline() or menu()

We currently use heuristics to determine these cases (see prompt_info).

Since posit-dev/ark#346, we have made the detection of debug prompts more reliable at the expense of the detection of readline prompts. Here is a reprex:

foo <- function() {
  bar()
  NULL
}

bar <- function() {
  readline("foo ")
}

debug(foo)
foo()

Ark drops in the debugger again, inside readline().

Screenshot 2024-09-19 at 12 40 10

Possible fixes:

  • Eventually we would like to contribute an extended ReadConsoleExt() hook to R where contextual information would be passed via a struct. Then we would know for sure what kind of prompts we're dealing with.

  • In the meantime we could detect readline() or menu() on the stack and never drop in the debugger in that case, and instead treat the prompt like a readline request. However that would get us in a weird state with debug(readline) (or a user stepping in it by accident with F11).

  • We could match Browse[%d]> in the prompt string. If it matches, it's a browser prompt, otherwise, it's a readline prompt running within a debug session. We could still be tricked by readline("Browse[0]> ") but I think that's ok.

@lionel- lionel- added area: console Issues related to Console category. lang: r area: kernels Issues related to Jupyter kernels and LSP servers labels Sep 19, 2024
@lionel- lionel- added this to the 2024.10.0 Pre-Release milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: console Issues related to Console category. area: kernels Issues related to Jupyter kernels and LSP servers lang: r
Projects
None yet
Development

No branches or pull requests

1 participant