vscode-code-runner icon indicating copy to clipboard operation
vscode-code-runner copied to clipboard

[Bug] Issue with Code Runner Extension When Terminal is Already Running a Process

Open 1Gireesh opened this issue 2 years ago • 4 comments

Subject: Issue with Code Runner Extension When Terminal is Already Running a Process

Description:

I am encountering an issue with the Code Runner extension in Visual Studio Code when I have a terminal open that is already running a process. When I open a different file and click on the "Run" button, the extension attempts to execute the command in the existing terminal, which is reserved for the previous process. Ideally, it should open a new instance or tab of the terminal to run the new command.

Steps to Reproduce:

  1. Open a terminal in VS Code.
  2. Start a long-running process or server in the terminal, so it remains active.
  3. Open a different file in VS Code.
  4. Click on the "Run" button for the code in the new file.

Expected Behavior:

I expected the Code Runner extension to open a new terminal instance or tab to run the command from the new file, even when a terminal with a running process is already open. This behavior would prevent conflicts with the existing terminal.

Actual Behavior:

The Code Runner extension attempts to execute the command in the existing terminal, which is already reserved for the previous process. This can cause confusion and conflicts.

Environment:

  • Visual Studio Code Version: 1.82.2
  • Code Runner Extension Version: [0.12.0]
  • Operating System: [Debian 13 Linux]

demo video screen-record-bug.webm

1Gireesh avatar Sep 25 '23 14:09 1Gireesh

Bhai koi solution mila????

Nimish05Z avatar Oct 28 '25 13:10 Nimish05Z

Nope, I am not aware I stopped using Code Runner a long time ago.

23f2005217 avatar Oct 28 '25 13:10 23f2005217

Any alternative??

Nimish05Z avatar Oct 28 '25 13:10 Nimish05Z

I have custom bash alias something like `run() { if [ "$1" = "-n" ]; then nodemon_mode=true shift else nodemon_mode=false fi

file="$1"
if [ -z "$file" ]; then
    echo "Usage: run [-n] <file>"
    return 1
fi

ext="${file##*.}"
case "$ext" in
    py) runner="python" ;;
    js) runner="node" ;;
    ts) runner="ts-node" ;;
    c)
        out="${file%.*}"
        gcc "$file" -o "$out" && runner="./$out"
        ;;
    cpp)
        out="${file%.*}"
        g++ "$file" -o "$out" && runner="./$out"
        ;;
    java)
        javac "$file" && runner="java ${file%.*}"
        ;;
    sh) runner="bash" ;;
    rb) runner="ruby" ;;
    go) runner="go run" ;;
    php) runner="php" ;;
    *)
        echo "Unsupported file type: .$ext"
        return 1
        ;;
esac

if [ "$nodemon_mode" = true ]; then
    nodemon --exec "$runner" "$file" -q
else
    $runner "$file"
fi

}`

I put this in my .bashrc and .zshrc file So if do run -n filename.py it will keep listening to changes and it will run the file on save

23f2005217 avatar Oct 28 '25 14:10 23f2005217