execute command disabled, when query has not connection

This commit is contained in:
Jan Prochazka
2021-05-06 09:43:32 +02:00
parent cd7edcb443
commit 0b8add848a
2 changed files with 10 additions and 1 deletions

View File

@@ -241,6 +241,7 @@ export function registerFileCommands({
toggleComment = false, toggleComment = false,
findReplace = false, findReplace = false,
undoRedo = false, undoRedo = false,
executeAdditionalCondition = null,
}) { }) {
if (save) { if (save) {
registerCommand({ registerCommand({
@@ -274,7 +275,10 @@ export function registerFileCommands({
toolbar: true, toolbar: true,
isRelatedToTab: true, isRelatedToTab: true,
keyText: 'F5 | Ctrl+Enter', keyText: 'F5 | Ctrl+Enter',
testEnabled: () => getCurrentEditor() != null && !getCurrentEditor()?.isBusy(), testEnabled: () =>
getCurrentEditor() != null &&
!getCurrentEditor()?.isBusy() &&
(executeAdditionalCondition == null || executeAdditionalCondition()),
onClick: () => getCurrentEditor().execute(), onClick: () => getCurrentEditor().execute(),
}); });
registerCommand({ registerCommand({

View File

@@ -27,6 +27,7 @@
execute: true, execute: true,
toggleComment: true, toggleComment: true,
findReplace: true, findReplace: true,
executeAdditionalCondition: () => getCurrentEditor()?.hasConnection(),
}); });
</script> </script>
@@ -121,6 +122,10 @@
return tabid; return tabid;
} }
export function hasConnection() {
return !!conid;
}
export async function execute() { export async function execute() {
if (busy) return; if (busy) return;
executeNumber++; executeNumber++;