posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.59k stars 79 forks source link

Console: disallow typing in the console before the runtime has started or queue statements for execution #3085

Open testlabauto opened 5 months ago

testlabauto commented 5 months ago

Positron Version: 2024.05.0 (Universal) build 1151

Steps to reproduce the issue:

  1. Select a new interpreter (more likely to occur with Python)
  2. Very rapidly start using the console (before you see the "started" indication). In other words, while the interpreter is still "starting", try to enter some code into the console
  3. Note that the three dots indicating a continued line will appear and the code will not be processed.

What did you expect to happen?

I would have expected that the code would be queued until the interpreter was started, then executed.

Were there any error messages in the output or Developer Tools console?

I didn't see any error messages. See the attached screenshot for what Positron looks like when this happens.

playwright-screenshot-1-postEnterKey

jmcphers commented 5 months ago

I believe the underlying problem here is that the console is trying to test the code for completeness (i.e. determining whether the statement should be evaluated or the user prompted to enter more lines), but it isn't working because Python is still Starting and therefore not able to accept messages yet.

If you want to reproduce this at a more casual pace, you can use R and add a Sys.sleep(20) to your .Rprofile so that R hangs out in Starting for a while.

I think that in this case the code should be queued for execution without performing any checks to see whether it's complete or not. If you manage to run code before startup finishes, you're probably sending it from the editor rather than typing it by hand, so it probably benefits from the statement range provider.

seeM commented 4 months ago

+1 for queuing statements for execution instead of disallowing typing. Most terminals/consoles do that, so disallowing typing can feel quite jarring in my experience.

seeM commented 4 months ago

I just noticed that if you do Cmd+Shift+0 and then very quickly Cmd+Enter, it appears in the console for a moment and is then lost. It might also be related to this issue.

I noticed this because I've been finding myself wanting to do Cmd+Shift+0 -> Cmd+Shift+Enter very quickly to "restart and run all" while developing in Python. That doesn't currently work either.

https://github.com/posit-dev/positron/assets/559360/2b8db06e-649a-4867-99ea-2f13304ba191