Skip to content

Commit

Permalink
Fix: Resolve devtool workspace for new eSDK projects
Browse files Browse the repository at this point in the history
When opening a fresh eSDK, there is no devtool workspace open yet. The
previous logic had to wait before resolving. This made the "New devtool
workspace" missing from the tree view.
  • Loading branch information
deribaucourt committed Feb 6, 2024
1 parent 682e7bc commit 392e6c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 2 additions & 4 deletions client/src/ui/BitbakeRecipesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ class BitbakeTreeDataProvider implements vscode.TreeDataProvider<BitbakeRecipeTr
return []
}

if (this.bitbakeScanResults === undefined) {
while (this.bitbakeScanResults === undefined) {
await new Promise(resolve => setTimeout(resolve, 300))
}
while (this.bitbakeScanResults === undefined) {
await new Promise(resolve => setTimeout(resolve, 300))
}
const fileItems: BitbakeRecipeTreeItem[] = []
this.bitbakeScanResults._recipes.forEach((recipe: ElementInfo) => {
Expand Down
13 changes: 7 additions & 6 deletions client/src/ui/DevtoolWorkspacesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export class DevtoolWorkspacesView {
class DevtoolTreeDataProvider implements vscode.TreeDataProvider<DevtoolWorkspaceTreeItem> {
private readonly _onDidChangeTreeData: vscode.EventEmitter<DevtoolWorkspaceTreeItem | undefined> = new vscode.EventEmitter<DevtoolWorkspaceTreeItem | undefined>()
readonly onDidChangeTreeData: vscode.Event<DevtoolWorkspaceTreeItem | undefined> = this._onDidChangeTreeData.event
private bitbakeScanResults: BitbakeScanResult = { _layers: [], _classes: [], _includes: [], _recipes: [], _overrides: [], _workspaces: [] }
private bitbakeScanResults: BitbakeScanResult | undefined

constructor (bitbakeProjectScanner: BitBakeProjectScanner) {
bitbakeProjectScanner.onChange.on('scanReady', (scanResults: BitbakeScanResult) => {
// In case a parsing error was just introduced, we keep the previous results to keep navigation functional
if (!scanContainsData(this.bitbakeScanResults) || scanContainsData(scanResults)) {
if (this.bitbakeScanResults === undefined || !scanContainsData(this.bitbakeScanResults) || scanContainsData(scanResults)) {
this.bitbakeScanResults = scanResults
}
this._onDidChangeTreeData.fire(undefined)
Expand All @@ -42,10 +42,8 @@ class DevtoolTreeDataProvider implements vscode.TreeDataProvider<DevtoolWorkspac

async getChildren (element?: DevtoolWorkspaceTreeItem | undefined): Promise<DevtoolWorkspaceTreeItem[]> {
if (element === undefined) {
if (!scanContainsData(this.bitbakeScanResults)) {
while (!scanContainsData(this.bitbakeScanResults)) {
await new Promise(resolve => setTimeout(resolve, 300))
}
while (this.bitbakeScanResults === undefined) {
await new Promise(resolve => setTimeout(resolve, 300))
}
const items = this.getDevtoolWorkspaces()
items.push(this.getAddWorkspaceItem())
Expand All @@ -57,6 +55,9 @@ class DevtoolTreeDataProvider implements vscode.TreeDataProvider<DevtoolWorkspac
}

private getDevtoolWorkspaces (): DevtoolWorkspaceTreeItem[] {
if (this.bitbakeScanResults === undefined) {
return []
}
return this.bitbakeScanResults._workspaces.map((workspace: DevtoolWorkspaceInfo) => {
return new DevtoolWorkspaceTreeItem(workspace)
})
Expand Down

0 comments on commit 392e6c0

Please sign in to comment.