-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Unnecessary delay when opening a terminal #29184
Comments
@fabiospampinato the problem is that the terminal takes more than 0ms to start up? It takes time to spin up the pty and attach everything, a little longer than other terminals because everything is going through V8 first. |
@Tyriar the problem is that I have to put workarounds in my AppleScripts in order for them to work. Of course it won't be as fast as a native terminal, but perhaps instead of just throwing away whatever is typed during the time where the terminal panel is in focus but the new pty hasn't started yet we could store it and replay it back once the pty started. What do you think? |
Sure, I'll add it to the backlog and open it up for PRs. To anyone interested in implementing this you will need to listen to key strokes in TerminalInstance and add them to a queue. Once the pty is ready then push the events through the normal mechanism. |
Sounds nice, thanks! |
@fabiospampinato |
I haven't looked at the code yet, but I'm assuming there could be some state awareness issues. I also realized my situation with the VSC run commands is related but different since the run command is an internal command. I'll look into what I think this takes |
@cleidigh yes there are some async calls between toggling the terminal and the terminal actually coming up. It's possible this won't actually fix the issue of using a 0 delay, but it would definitely be beneficial to Windows in particular as I have keystrokes going missing all the time when I'm typing fast due to the increase time it takes to launch the shell. |
@Tyriar |
@fabiospampinato |
@cleidigh what I want to do is set-up a bunch of terminals, each of them might |
@fabiospampinato the typical way to do this is to create an extension which should give you enough to be able to create several terminals and if you want give them custom names/shells. I still feel like this request adds value regardless of the direction you go though 😃 |
@fabiospampinato I recommend checking out https://code.visualstudio.com/docs/extensionAPI/vscode-api#window.createTerminal as well as the Task APIs currently in a proposed state: https://github.com/Microsoft/vscode/blob/master/src/vs/vscode.proposed.d.ts |
@Tyriar Well, I simply took the easy/fast route: having a program typing keystrokes for me. I'll check those links out, thanks! |
@Tyriar |
@Tyriar
am I missing some other mechanism that would effectively allow change of context and focus |
@cleidigh I think xterm.js should get and process events before the process is ready. I was imagining queuing up the data from xterm.js from here instead of just discarding it https://github.com/Microsoft/vscode/blob/75082c7ecba8ea75a2bc8a75d41768eebcb04225/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts#L213 and sending it through when |
@Tyriar |
@cleidigh the delay is due to the process warming up, xterm.js which handles the input events should be attached very quickly. I don't think it's worth pursuing this beyond holding onto what xterm.js wants to give us and making sure that the process is ready before sending it. |
@Tyriar I have a solution working that is pretty much lossless. I know the solution (Q the actual keyboard events and replay them when process ready) |
@Tyriar After lots of experimentation and a better understanding the sequence and escape encoding location
I did a fair amount of testing. as you may remember I use Dragon voice recognition with my own Python extensions for everything (because of the ALS) This allows me to send characters I have posted a PR #30106 Hope that looks good. |
Q data during pty launch delay Fixes: #29184
Sounds great, thanks a lot for your time! |
@fabiospampinato thanks for the suggestion, this will make things feel much snappier 🙂 |
@fabiospampinato using the exact same script as @fabiospampinato I can reproduce the problem as stated at the beginning of this issue. with the data to fix keystrokes to not appear lost but there is a double rendering |
@cleidigh the time to input is as small as it can get in a nice way imo, for the OP's case I'd say making an extension to drive the terminal would be a much more reliable way of scripting VS Code. |
@Tyriar |
@cleidigh well I can definitely notice the difference on macOS as well 👍 |
@Tyriar |
@fabiospampinato that's really cool! I'm going to share it with the team and in #20013 |
The Issue
I'm writing an AppleScript for opening a terminal and writing some stuff in it, the problem is that without an hard coded delay between the action "open the terminal" and the action "write this stuff in it" it doesn't work.
This is what, ideally, should be working (minus the useless delay call):
This is what I see in the terminal if I run the AppleScript with different delay values:
fabiomac:project fabio$
❌fabiomac:project fabio$
❌placeholderfabiomac:project fabio$ placeholder
❌ 😮fabiomac:project fabio$ placeholder
✅IMHO this is broken because I shouldn't have to hard code environment-dependant delay calls in my AppleScripts, and consequentially I shouldn't have to wait those extra seconds.
My Setup
The text was updated successfully, but these errors were encountered: