-
Notifications
You must be signed in to change notification settings - Fork 835
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
unable to quit app from the keyboard within vscode #5385
Comments
I'm not a VS Code user, but apparently you can use this setting to send the keybinding to the terminal instead: https://code.visualstudio.com/docs/terminal/advanced#_keybinding-and-the-shell |
In my opinion, proper solution would be to change vscode keyboard shortcuts. Anyway I worked around this situation by adding custom key binding to my textual app. I just use 'q', I actually like it more than Ctrl+'q': BINDINGS = [
Binding(key="q", action="quit", description="Quit the app"),
...
] |
We're definitely not going to get into the business of having different keybinds for different terminals/environments. If it matters to you you can add a custom binding (as you did) or use keymaps to load a different key when VSCode is in use. (On re-reading I'm not sure if you mean Textual should detect VSCode and offer different shortcuts, or VSCode users should change their own keyboard shortcuts) |
IMO the real trouble here is that for many users they simply won't be able to figure out how to quit without hard-aborting the terminal (a SIGKILL, which will likely block any standard cleanup the process does). Remember, Ctrl+C (the gesture that most user instinctively know) is now blocked entirely and the user is told to use Ctrl+Q instead. If they then try this and it fails due to VS Code taking, they have to (a) Realise that this is what the problem is; and (b) Sort out how to block the Ctrl+Q keyboard shortcut can be disabled in VS Code. My bet is that most users won't be able to sort this out, leaving the situation that Textual apps in VS Code are difficult to quit and impossible to interrupt gracefully. A reasonable compromise position might be to stop blocking Ctrl+C? |
You can still assign The problem is |
Yes, that's what we did. While I'm happy we found a workaround I was just wondering if textual (in general via its defaults) wanted to make it easy to quit apps in VS Code (I think right now it's quite difficult for users to figure out how to quit apps, at least in a way that enables the app to clean up). There is plenty of precedent for keys that behave differently inside text inputs -- i.e. in modal dialogs the enter key usually accepts the dialog but while in a text area it inserts a newline. I don't think it would be incoherent at all to say that Ctrl+C works to quit unless you are in a textarea. |
Having If it is an issue for you, then I think remapping that key in your app is the only solution. |
Interesting, if you execute the Preferences: Open Default Keyboard Shortcuts (JSON) command on a Mac and look for ctrl+q it does appear mapped to the From my standpoint this is completely resolved as I have the workaround you mentioned in hand, was just trying make sure you understood that users may in general struggle with quitting textual apps (of course only if I am correct about Ctrl+Q). |
|
Can you guys see ctrl+q when you run |
No, it doesn't show up when I press it while running |
Also no, unless I set |
There are a number of keybindings that will "skip the shell" in VS Code, as explained in the link above. Presumably Will you have some configuration or extension that overrides those defaults. Trying to run TUIs in embedded IDE terminals inherently has some limitations. I don't expect Textual to change its keybindings just to accommodate VS Code. |
It might be related to the terminal in use. Notice Will is running zsh. I've had no problems on Windows using MingW as the default terminal. |
You can reproduce this behaviour by running this repo in Codespaces and then running one of the examples (I chose If you select the button in the message it directs you to Settings where there's a setting "Terminal > Integrated: Send Keybindings To Shell" which is off by default. I guess this is more a VS Code issue but as a Textual noob I encountered it recently and was somewhat vexed that I had to then remove those shortcuts (which, true, I wasn't using anyway). I only recently found out about the Send Keybindings To Shell setting and am hesitant to enable it lest there be side-effects. Rather than enabling the use of |
With the recent change to trapping Ctrl+C and asking the user to press Ctrl+Q, it is no longer possible to quit textual applications from the keyboard within VS Code (as VS Code takes the Ctrl+Q and executes another command, preventing textual from seeing the key-compo.
Here is a video where I attempt to press Ctrl+C, get the message, then press Ctrl+Q twice (note VS code takes the key):
textual-quit.mov
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: