簡體   English   中英

為什么我執行Python時,Code Runner總是在VSCode中打開其他終端? 以及如何解決?

[英]Why Code Runner always open other terminal in VSCode when I execute Python? And how to fix it?

即使已經打開了一個終端,當我使用Code Runner ( ctrl + alt + n ) 運行Python代碼時,在 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"

我該如何解決這種奇怪的行為?

謝謝

這是代碼運行器的問題清除之前的 output,將其設置為 false 並手動將清除命令添加到其執行程序 map,最終結果應如下所示。 所有這些都在項目的 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",
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM