Skip to content

Commit

Permalink
added hijack button
Browse files Browse the repository at this point in the history
  • Loading branch information
franneck94 committed Jul 31, 2023
1 parent e11b130 commit 3addc45
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@
"title": "Generate Assembler Code",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.BuildAndDebugFile",
"title": "C/C++ Runner: Debug File",
"category": "C/C++",
"icon": "$(debug-alt)"
},
{
"command": "C_Cpp_Runner.BuildAndRunFile",
"title": "C/C++ Runner: Run File",
"category": "C/C++",
"icon": "$(run)"
}
],
"keybindings": [
Expand Down Expand Up @@ -194,6 +206,16 @@
"when": "explorerResourceIsFolder",
"group": "cCppRunnerGroup@1"
}
],
"editor/title/run": [
{
"command": "C_Cpp_Runner.BuildAndDebugFile",
"when": "editorLangId =~ /^(c|(cuda-)?cpp)$/"
},
{
"command": "C_Cpp_Runner.BuildAndRunFile",
"when": "editorLangId =~ /^(c|(cuda-)?cpp)$/"
}
]
},
"configuration": {
Expand Down
33 changes: 33 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export function activate(context: vscode.ExtensionContext) {
initWorkspaceProvider();
initWorkspaceDisposables();
initEventListener();

initEditorBuildDebug();
initEditorBuildRun();
}

export function deactivate() {
Expand Down Expand Up @@ -254,6 +257,36 @@ function initEventListener() {
initFileDeleteDisposable();
}

function initEditorBuildDebug() {
extensionContext?.subscriptions.push(
vscode.commands.registerTextEditorCommand(
'C_Cpp_Runner.BuildAndDebugFile',
async () => {
const commandNameBuild = `${EXTENSION_NAME}.buildSingleFile`;
await vscode.commands.executeCommand(commandNameBuild);

const commandNameDebug = `${EXTENSION_NAME}.debugCurrentSelection`;
await vscode.commands.executeCommand(commandNameDebug);
},
),
);
}

function initEditorBuildRun() {
extensionContext?.subscriptions.push(
vscode.commands.registerTextEditorCommand(
'C_Cpp_Runner.BuildAndRunFile',
async () => {
const commandNameBuild = `${EXTENSION_NAME}.buildSingleFile`;
await vscode.commands.executeCommand(commandNameBuild);

const commandNameRun = `${EXTENSION_NAME}.runCurrentSelection`;
await vscode.commands.executeCommand(commandNameRun);
},
),
);
}

function initConfigurationChangeDisposable() {
if (eventConfigurationDisposable) return;

Expand Down

0 comments on commit 3addc45

Please sign in to comment.