From 29fd3110ab297cde4b030d52e709747314b9b17c Mon Sep 17 00:00:00 2001 From: Enguerrand de Ribaucourt Date: Wed, 22 Nov 2023 16:20:35 +0100 Subject: [PATCH] Fix: Enqueue onSave parsing in case of concurrent parse requests --- client/src/ui/BitbakeCommands.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/src/ui/BitbakeCommands.ts b/client/src/ui/BitbakeCommands.ts index ab889c6dc..f4e70b67e 100644 --- a/client/src/ui/BitbakeCommands.ts +++ b/client/src/ui/BitbakeCommands.ts @@ -13,6 +13,8 @@ import { type BitbakeTaskProvider } from './BitbakeTaskProvider' import path from 'path' import { BitbakeRecipeTreeItem } from './BitbakeRecipesView' +let parsingPending = false + export function registerBitbakeCommands (context: vscode.ExtensionContext, bitbakeWorkspace: BitbakeWorkspace, bitbakeTaskProvider: BitbakeTaskProvider): void { context.subscriptions.push(vscode.commands.registerCommand('bitbake.parse-recipes', async () => { await parseAllrecipes(bitbakeWorkspace, bitbakeTaskProvider) })) context.subscriptions.push(vscode.commands.registerCommand('bitbake.build-recipe', async (uri) => { await buildRecipeCommand(bitbakeWorkspace, bitbakeTaskProvider, uri) })) @@ -20,6 +22,17 @@ export function registerBitbakeCommands (context: vscode.ExtensionContext, bitba context.subscriptions.push(vscode.commands.registerCommand('bitbake.run-task', async (uri, task) => { await runTaskCommand(bitbakeWorkspace, bitbakeTaskProvider, uri, task) })) context.subscriptions.push(vscode.commands.registerCommand('bitbake.drop-recipe', async (uri) => { await dropRecipe(bitbakeWorkspace, uri) })) context.subscriptions.push(vscode.commands.registerCommand('bitbake.watch-recipe', async (recipe) => { await addActiveRecipe(bitbakeWorkspace, recipe) })) + + // Handles enqueued parsing requests (onSave) + context.subscriptions.push( + vscode.tasks.onDidEndTask((e) => { + if (e.execution.task.name === 'Parse all recipes') { + if (parsingPending) { + parsingPending = false + void parseAllrecipes(bitbakeWorkspace, bitbakeTaskProvider) + } + } + })) } async function parseAllrecipes (bitbakeWorkspace: BitbakeWorkspace, taskProvider: vscode.TaskProvider): Promise { @@ -33,6 +46,7 @@ async function parseAllrecipes (bitbakeWorkspace: BitbakeWorkspace, taskProvider const runningTasks = vscode.tasks.taskExecutions if (runningTasks.some((execution) => execution.task.name === parseAllRecipesTask.name)) { logger.debug('Parse all recipes task is already running') + parsingPending = true return } await runBitbakeTask(parseAllRecipesTask, taskProvider)