问题
In the regular windows terminal Control+C is keybound to SIGINT allowing you to break a running process. Visual Studio Code's Integrated Terminal enables you to have passthrough key commands through terminal.integrated.commandsToSkipShell, which is quite useful. Although Control+C is keybound to copy by default, SIGINT isn't readily apparent in the settings to set up a keybind for. How can you send SIGINT to the Visual Studio Code Integrated console, and preferably keybind it, so that you can signal processes to stop or interrupt?
Here is the documentation I was able to find, which unfortunately has no references to SIGINT or using Control+C for interrupts which I imagine is a common need: https://code.visualstudio.com/docs/editor/integrated-terminal
回答1:
It turns out that on Visual Studio Code for Windows, ctrl-c
and ctrl-v
among other commands are set to bypass the terminal and be handled by VSCode itself.
To fix simply open your preferences File>Preferences>Settings
(ctrl-,
) and add your own terminal.integrated.commandsToSkipShell
settings value. It's best to let VSCode do the work for you by using it's intellisense feature so that you get all the defaults included so that you don't accidentally change other behaviour you expected to work.
Then go ahead and remove the workbench.action.terminal.copySelection
to let ctrl-c
work and workbench.action.terminal.paste
to get ctrl-v
to work.
Pasting into the terminal will still work for ctrl-shift-v
but I haven't yet figured out how to make copying work. I'll update this answer if I do.
来源:https://stackoverflow.com/questions/43667317/sigint-in-visual-studio-code-integrated-terminal