Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom placeholders #1208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,21 @@
"description": "Set the executor of each file extension.",
"scope": "resource"
},
"code-runner.customParameters": {
"type": "array",
"default": [
{
"param": "example1",
"value": "ValueOf$example1"
},
{
"param": "example2",
"value": "ValueOf$example2"
}
],
"description": "add custom paramerts to the coderunner",
"scope": "resource"
},
"code-runner.customCommand": {
"type": "string",
"default": "echo Hello",
Expand Down
6 changes: 6 additions & 0 deletions src/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ export class CodeManager implements vscode.Disposable {
{ regex: /\$pythonPath/g, replaceValue: pythonPath },
];

let customParameters = this._config.get<any>("customParameters");
customParameters.forEach((customParameter) => {
let regex = new RegExp(`\\$${customParameter.param}`, 'g');
cmd = cmd.replace(regex, customParameter.value);
});

placeholders.forEach((placeholder) => {
cmd = cmd.replace(placeholder.regex, placeholder.replaceValue);
});
Expand Down