From c616bff548c4de7aee72160a00b838577c437741 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Fri, 20 Dec 2024 13:42:58 -0500 Subject: [PATCH] Disable check button when checker is running Signed-off-by: worksofliam --- package.json | 2 +- src/language/providers/contributes.json | 2 +- src/language/providers/problemProvider.ts | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5855848b..b86986ff 100644 --- a/package.json +++ b/package.json @@ -686,7 +686,7 @@ "command": "vscode-db2i.syntax.checkDocument", "title": "Check SQL syntax", "category": "Db2 for IBM i", - "enablement": "code-for-ibmi:connected == true && vscode-db2i:jobManager.hasJob && vscode-db2i:statementCanCancel != true && vscode-db2i.syntax.checkerAvailable == true", + "enablement": "code-for-ibmi:connected == true && vscode-db2i:jobManager.hasJob && vscode-db2i:statementCanCancel != true && vscode-db2i.syntax.checkerAvailable == true && vscode-db2i.syntax.checkerRunning != true", "icon": "$(check-all)" } ], diff --git a/src/language/providers/contributes.json b/src/language/providers/contributes.json index e49347bf..56b78d78 100644 --- a/src/language/providers/contributes.json +++ b/src/language/providers/contributes.json @@ -33,7 +33,7 @@ "command": "vscode-db2i.syntax.checkDocument", "title": "Check SQL syntax", "category": "Db2 for IBM i", - "enablement": "code-for-ibmi:connected == true && vscode-db2i:jobManager.hasJob && vscode-db2i:statementCanCancel != true && vscode-db2i.syntax.checkerAvailable == true", + "enablement": "code-for-ibmi:connected == true && vscode-db2i:jobManager.hasJob && vscode-db2i:statementCanCancel != true && vscode-db2i.syntax.checkerAvailable == true && vscode-db2i.syntax.checkerRunning != true", "icon": "$(check-all)" } ], diff --git a/src/language/providers/problemProvider.ts b/src/language/providers/problemProvider.ts index a10f5a01..16c338a2 100644 --- a/src/language/providers/problemProvider.ts +++ b/src/language/providers/problemProvider.ts @@ -47,12 +47,19 @@ function shouldShowWarnings() { } const CHECKER_AVAILABLE_CONTEXT = `vscode-db2i.syntax.checkerAvailable`; +const CHECKER_RUNNING_CONTEXT = `vscode-db2i.syntax.checkerRunning`; export function setCheckerAvailableContext() { const available = SQLStatementChecker.get() !== undefined; commands.executeCommand(`setContext`, CHECKER_AVAILABLE_CONTEXT, available); } +let checkerRunning = false; +export function setCheckerRunningContext(isRunning: boolean) { + checkerRunning = isRunning; + commands.executeCommand(`setContext`, CHECKER_RUNNING_CONTEXT, isRunning); +} + export const CHECK_DOCUMENT_COMMAND = `vscode-db2i.syntax.checkDocument`; export const checkDocumentDefintion = commands.registerCommand(CHECK_DOCUMENT_COMMAND, async (uri?: Uri) => { const document = uri ? (await workspace.openTextDocument(uri)) : window.activeTextEditor?.document; @@ -89,7 +96,8 @@ interface SqlDiagnostic extends Diagnostic { async function validateSqlDocument(document: TextDocument, specificStatement?: number) { const checker = SQLStatementChecker.get(); - if (remoteAssistIsEnabled() && checker) { + if (remoteAssistIsEnabled() && checker && !checkerRunning) { + setCheckerRunningContext(true); const content = document.getText(); const sqlDocument = new Document(content); @@ -162,7 +170,7 @@ async function validateSqlDocument(document: TextDocument, specificStatement?: n severity: diagnosticTypeMap[groupError.type], groupId: currentRange.groupId }; - + if (existingError >= 0) { currentErrors[existingError] = newDiag; } else { @@ -177,6 +185,8 @@ async function validateSqlDocument(document: TextDocument, specificStatement?: n } } } + + setCheckerRunningContext(false); } function shouldShowError(error: SqlSyntaxError) {