Is there any setting for vscode-code-runner to setup a file that would be always run when I click on run button regardless which file is open in editor currently.
as of writing this comment i do not believe it's possible with this extension. The next best thing i can recommend is to execute the file you want to run with coderunner, then copy the command that it generated and executed. You can then paste this command in your setting.json file as a custom command like so
{
"code-runner.customCommand": "<created command>",
}
To execute the custom command from anywhere in your workspace, do ctrl+alt+K
You can also create a launch.settings file to run and debug your code from the debug tab which you can then execute with ctrl+shift+D
it's not as slick as a nice run button but it's better than nothing
Related
Please can anyone help me out code runner only shows the right output after running the python file.
For example
Here I used the option "run python file" in terminal and it worked
Then i ran it using coderunner extension and it works
But when i change the output and run it, it doesn't change
It only changes after i run it with python file. So I have to run it in terminal for the right output to show. code runner only mirrors the last output in terminal
This may seem obvious but in the third picture, as you can see from the white circle on the tab where the x to close usually resides indicates that you have not saved the file hence it will output results from the last time you ran it using the 'run python file'. The 'run python file' button saves before running automatically so it would be easy to accidently miss the cause as now its saved with the new input and your code runner will output the new result again making it seem as though its duplicating the 'run python file' button.
Coming from IDLE, I am used to be able to just left-click python files anywhere, it'll launch IDLE, and then pressing F5 just runs the script. In VSCode however, I have to open the terminal, cd into the right directory, and only then can I finally run my python script. Is there a way to change this behavior?
I was recommended to use the Code Runner extention and bound the Run Code (code-runner.run) command to my F5 key.
Then I noticed input() not being ran so I had to make sure code-runner.runInTerminal was on, but that re-started my problem from the beginning because the terminal was at the wrong working directory and then I finally found the code-runner.fileDirectoryAsCwd setting to run it from there.
I think this solution is similar to this one for the python extention, but I'm not sure if that would cause the whole wrong working directory issue again.
choose from menu file then click on auto save
In my extension, I'm opening a local file using vscode.workspace.openTextDocument and then vscode.window.showTextDocument and vscode.workspace.onDidCloseTextDocument to close the file.
This seems to be working fine if run the extension using the code.
Now I have created the vsix file using vsce package. Here comes the tricky thing
Both vscode.workspace.onDidOpenTextDocument and vscode.workspace.onDidSaveTextDocument callbacks are called as expected. However
vscode.workspace.onDidCloseTextDocument callback is not called when I close the file in the UI.(I am facing this issue when the extension is installed.)
Am I missing anything?
Steps to Reproduce:
1) Open the file using vscode.workspace.openTextDocument and then vscode.window.showTextDocument.
2) Listen for events in vscode.workspace.onDidCloseTextDocument.
3) Close the file in the editor.
4) Check that vscode.workspace.onDidCloseTextDocument callback is not called as expected.
Code is present in this git repo https://github.com/akhilravuri1/hellovscode, please clone the code and create vsix package by typing vsce package command in the cmd. Install the extension using vsix file and select the hello world command then it will open a file but when you close it just closes but I expect a select option with YES or NO at command palette.
Thanks in Advance.
I tried your extension.
I get the OnClose-event when the Welcome Screen text editor closes and ddl.txt is loaded.
The docs say you should use the vscode.window on-events but they do not allow to monitor a document close.
Very strange that the OnClose-event is fired on language change (this happens). You can't tell if it is a language change or document close.
When I open the ddl.txt with File > Open and close it I get the OnClose-event.
I get the OnClose-event on all files opened with File > Open.
It looks like files opened with vscode.workspace.openTextDocument and vscode.window.showTextDocument do not fire an OnClose-event.
You should file a bug because these calls generate a normal TextDocument.
I'm working on a VSCode extension that get some inputs from the developer and calls some yarn/npm commands inside an custom opened terminal in order to generate a folder and some files inside it.
Everything is running ok, except that we need to manually click on the refresh button in the Explorer in order to see the resulting folder.
I would like to call a method from the extension to do that for us once the execution was completed.
I did some research on the web and found this command:
terminal.sendText(command);
vscode.commands.executeCommand(
"workbench.files.action.refreshFilesExplorer"
);
But unfortunately, it is not working as I expected.
Am I missing something ?
You likely need to wait until after the command has completed before running refresh.
Does the command need to be run in the terminal? Can it be run using node's child_process instead, with you then executing vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer") after the process exits?
If I open a file in Visual Studio Code from the command line or from within File Explorer, each file will open in a separate Code instance. Is there a way to make them all open in the same instance? I.e. add them all to the 'Working Files' list?
Upcoming version will have a new option files.openInNewWindow which you can set to off to always open files into the last active instance. This is then identical to starting VS Code with the -r option but is much nicer to use (e.g. when you open a file from the desktop).
Update for our VS Code 1.0 release:
The setting is available as window.openFilesInNewWindow
You can use the command line option of -r or --reuse-window to assure it opens in the last active VS Code window
You can review the other options here
code Folder1/File1.txt Folder2/File2.java Folder3/File3.css
This command opens three files in one instance of the editor. All files are going to be added to the working files list.
This even works with much more files in the parameter list.