如何将焦点返回到VS Code宏中的编辑器,将Python文本发送到调试控制台? [英] How to return focus to editor in VS Code macro sending Python text to Debug Console?
问题描述
我试图键绑定宏蟒蛇文本到调试控制台并返回焦点发送到Visual Studio代码编辑器.这是我曾尝试:
I have tried to key-bind a macro to send python text to the Debug Console and return focus to the editor in Visual Studio Code. This is what I have tried:
- 安装了 vscode-python 扩展
- 安装了宏扩展程序
- Installed the vscode-python extension
- Installed the macros extension
settings.json
:
{
"macros": {
"selectionToReplAndReturnToEditor": [
"editor.debug.action.selectionToRepl",
"workbench.action.focusActiveEditorGroup"
]
}
}
keybindings.json
:
[
{
"key": "alt+f9",
"command": "workbench.action.focusActiveEditorGroup",
},
{
"key": "alt+f10",
"command": "workbench.debug.action.focusRepl",
},
{
"key": "ctrl+enter",
"command": "macros.selectionToReplAndReturnToEditor",
"when": "editorTextFocus && editorHasSelection && editorLangId == 'python' && inDebugMode"
}
]
现在, Ctrl + Enter 确实会在调试控制台中执行文本,但不会将焦点返回给编辑器. 控制 + 输入接着替代 + F9 确实如此,但当然,我想结合单一钥匙.难道我做错了什么?我需要在宏中等待一些时间吗?我怎样才能做到这一点?
Now, Ctrl+Enter does execute text in the Debug Console, but does not return focus to the editor. Ctrl+Enter followed by Alt+F9 does that, but of course, I would like to bind a single key. Am I doing something wrong? Do I need some wait time in the macro? How can I achieve that?
推荐答案
此方法使用不同的扩展名:
This works, using a different extension:
"multiCommand.commands": [ // requires vscode:extension/ryuta46.multi-command
{ // ctrl+enter, editorTextFocus && editorHasSelection && editorLangId == 'python' && inDebugMode
"command": "multiCommand.selectionToReplAndReturnToEditor",
"sequence": [
"editor.debug.action.selectionToRepl",
"workbench.action.focusActiveEditorGroup",
]
},
}
这篇关于如何将焦点返回到VS Code宏中的编辑器,将Python文本发送到调试控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!