diff --git a/packages/web/src/commands/stdCommands.ts b/packages/web/src/commands/stdCommands.ts index e145139db..ee2d65127 100644 --- a/packages/web/src/commands/stdCommands.ts +++ b/packages/web/src/commands/stdCommands.ts @@ -241,6 +241,7 @@ export function registerFileCommands({ toggleComment = false, findReplace = false, undoRedo = false, + executeAdditionalCondition = null, }) { if (save) { registerCommand({ @@ -274,7 +275,10 @@ export function registerFileCommands({ toolbar: true, isRelatedToTab: true, keyText: 'F5 | Ctrl+Enter', - testEnabled: () => getCurrentEditor() != null && !getCurrentEditor()?.isBusy(), + testEnabled: () => + getCurrentEditor() != null && + !getCurrentEditor()?.isBusy() && + (executeAdditionalCondition == null || executeAdditionalCondition()), onClick: () => getCurrentEditor().execute(), }); registerCommand({ diff --git a/packages/web/src/tabs/QueryTab.svelte b/packages/web/src/tabs/QueryTab.svelte index 9c981cdfc..a2fcadb63 100644 --- a/packages/web/src/tabs/QueryTab.svelte +++ b/packages/web/src/tabs/QueryTab.svelte @@ -27,6 +27,7 @@ execute: true, toggleComment: true, findReplace: true, + executeAdditionalCondition: () => getCurrentEditor()?.hasConnection(), }); @@ -121,6 +122,10 @@ return tabid; } + export function hasConnection() { + return !!conid; + } + export async function execute() { if (busy) return; executeNumber++;