Skip to content

Commit

Permalink
Fix: Enqueue onSave parsing in case of concurrent parse requests
Browse files Browse the repository at this point in the history
  • Loading branch information
deribaucourt committed Nov 23, 2023
1 parent 68e03ea commit 29fd311
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client/src/ui/BitbakeCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@ 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) }))
context.subscriptions.push(vscode.commands.registerCommand('bitbake.clean-recipe', async (uri) => { await cleanRecipeCommand(bitbakeWorkspace, bitbakeTaskProvider, uri) }))
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<void> {
Expand All @@ -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)
Expand Down

0 comments on commit 29fd311

Please sign in to comment.