Skip to content

Commit

Permalink
auto build on loss of visibility or focus
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondaming committed Oct 21, 2024
1 parent 22d2db4 commit 493aac6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions vscode-wpilib/media/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
document.getElementById('refresh-action')?.addEventListener('click', () => {
vscode.postMessage({ type: 'refresh' })
});

// Listen for focus events
window.addEventListener('blur', () => {
vscode.postMessage({ type: 'blur' });
});
}

function addDropdownListeners() {
Expand Down
16 changes: 14 additions & 2 deletions vscode-wpilib/src/dependencyView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export class DependencyViewProvider implements vscode.WebviewViewProvider {
void this.refresh(this.wp);
} else {
if (this.changed > this.vendorLibraries.getLastBuild()) {
this.vendorLibraries.offerBuild(this.wp, true);
//this.vendorLibraries.offerBuild(this.wp, true);
this.externalApi.getBuildTestAPI().buildCode(this.wp, undefined);
this.changed = 0;
}
}
Expand Down Expand Up @@ -127,6 +128,17 @@ export class DependencyViewProvider implements vscode.WebviewViewProvider {
}
break;
}
case 'blur':
{
if (this.wp) {
if (this.changed > this.vendorLibraries.getLastBuild()) {
//this.vendorLibraries.offerBuild(this.wp, true);
this.externalApi.getBuildTestAPI().buildCode(this.wp, undefined);
this.changed = 0;
}
}
break;
}
default:
{
break;
Expand Down Expand Up @@ -213,7 +225,7 @@ export class DependencyViewProvider implements vscode.WebviewViewProvider {
const success = await this.vendorLibraries.installDependency(dep, this.vendorLibraries.getWpVendorFolder(this.wp), true);

if (success) {
this.vendorLibraries.offerBuild(this.wp);
// this.vendorLibraries.offerBuild(this.wp);
this.changed = Date.now();
}
}
Expand Down
2 changes: 1 addition & 1 deletion vscode-wpilib/src/vendorlibraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class VendorLibraries extends VendorLibrariesBase {
}

if (anySucceeded) {
this.offerBuild(workspace);
// this.offerBuild(workspace);
}
}
return anySucceeded;
Expand Down

0 comments on commit 493aac6

Please sign in to comment.