即使已经打开了一个终端,当我使用
Python
(Code Runner
) 运行 ctrl + alt + n
代码时,在 VSCode 中它总是会打开另一个终端。关闭旧的也没有用,因为它会再次打开。
这是我的终端、Python 和 Code Runner 的配置:
终端:
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.letterSpacing": 1,
代码运行者:
"code-runner.clearPreviousOutput": true,
"code-runner.saveAllFilesBeforeRun": true,
"code-runner.ignoreSelection": true,
"code-runner.runInTerminal": true, //only 2 Python
"code-runner.executorMap": {
"javascript": "node",
"python": "venv\\Scripts\\python.exe -u", //code-runner exec python of venv
"bat": "cmd /c"
},
Python:
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 500,
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.insertSpaces": true
},
"python.pythonPath": "venv\\Scripts\\python.exe",
"python.analysis.completeFunctionParens": true,
"python.linting.flake8Enabled": true,
"python.linting.pycodestyleEnabled": true,
"python.linting.pycodestylePath": "[MyPathHere]",
"python.linting.flake8Path": "[MyPathHere]",
"python.formatting.provider": "black"
如何解决这种奇怪的行为?
谢谢
这是代码运行程序清除以前的输出的问题,将其设置为 false 并手动将清除命令添加到其执行器映射中,最终结果应该如下所示。所有这些都将在项目的 settings.json 文件中完成,位于 .vscode 文件夹下。
{
"code-runner.runInTerminal": true,
"code-runner.clearPreviousOutput": false,
"code-runner.executorMap": {
"c": "clear; cd $dir && gcc $fileName -o $fileNameWithoutExt &&
$dir$fileNameWithoutExt",
"cpp": "clear; cd $dir && g++ $fileName -o $fileNameWithoutExt &&
$dir$fileNameWithoutExt",
}
}