Skip to content

Commit b51f1b3

Browse files
committed
Add Source Current File button
1 parent 5bd4f57 commit b51f1b3

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

ggsql-vscode/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@
5555
"languageId": "ggsql"
5656
}
5757
],
58+
"commands": [
59+
{
60+
"command": "ggsql.sourceCurrentFile",
61+
"category": "ggsql",
62+
"title": "Source Current File",
63+
"icon": "$(play)"
64+
}
65+
],
66+
"menus": {
67+
"editor/title/run": [
68+
{
69+
"command": "ggsql.sourceCurrentFile",
70+
"group": "navigation@0",
71+
"when": "resourceLangId == ggsql && !isInDiffEditor"
72+
},
73+
{
74+
"command": "workbench.action.positronConsole.executeCode",
75+
"when": "resourceLangId == ggsql && !isInDiffEditor"
76+
}
77+
]
78+
},
5879
"configuration": {
5980
"type": "object",
6081
"title": "ggsql",

ggsql-vscode/src/extension.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ export function activate(context: vscode.ExtensionContext): void {
5252
}
5353

5454
log(`Registered ${drivers.length} connection drivers`);
55+
56+
// Register "Source Current File" command for the editor run button
57+
context.subscriptions.push(
58+
vscode.commands.registerCommand('ggsql.sourceCurrentFile', async () => {
59+
const editor = vscode.window.activeTextEditor;
60+
if (!editor || editor.document.languageId !== 'ggsql') {
61+
return;
62+
}
63+
const code = editor.document.getText();
64+
if (code.trim().length === 0) {
65+
return;
66+
}
67+
positronApi.runtime.executeCode('ggsql', code, true);
68+
})
69+
);
5570
}
5671

5772
/**

0 commit comments

Comments
 (0)