formulahendry / vscode-code-runner

Code Runner for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
MIT License
2.21k stars 298 forks source link

The code execution command is pasted in the terminal after a potential unexecuted command. Should first clear the terminal prompt #403

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi, I hope this hasn't already been discussed; I wasn't able to find anything related in the issues.

Describe the bug Pressing Ctrl + Alt + N when the terminal already has an unexecuted command pastes the execution command after this unexecuted command, usually resulting in a benine error.

To Reproduce Steps to reproduce the behavior:

  1. Open VSCode and terminal
  2. Execute code runner: Ctrl + Alt + N
  3. Now in the opened terminal, type any harmless string, such as $ eee, without executing
  4. Switch to the editor window and press Ctrl + Alt + N again

Actual behavior Taking python as an example, the executed command is $ eee/usr/bin/env python "/my/path/myfile.py" As can be expected, this results in: bash: eee/usr/bin/env: No such file or directory

Expected behavior I expected code runner to first clear what's already been typed in the terminal prompt.

In my case this often happens when I inadvertently press the Up arrow in the terminal after execution, which pastes the previous command in the terminal prompt, then go back to the editor window and try to execute the code.

escape0707 commented 5 years ago

This problem has confused me for a long time, too.

For now I prefix the executorMap command with \b\b\b\b\b\b\b or foo &> /dev/null ;.

I hope there is a way to clean the input buffer first, or, to let me embed a ctrl+u into the executorMap.