Skip to content

Commit

Permalink
fix: Task and its pinned version not synchronized (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
CsCherrYY authored Aug 9, 2022
1 parent a3d41be commit e3992ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const gradleTaskTreeItemMap: Map<string, GradleTaskTreeItem> = new Map();
const gradleProjectTreeItemMap: Map<string, RootProjectTreeItem> = new Map();
const projectTreeItemMap: Map<string, ProjectTreeItem> = new Map();
const groupTreeItemMap: Map<string, GroupTreeItem> = new Map();
const pinnedTaskTreeItemMap: Map<string, GradleTaskTreeItem> = new Map();

export function getGradleTaskTreeItemMap(): Map<string, GradleTaskTreeItem> {
return gradleTaskTreeItemMap;
Expand All @@ -39,11 +40,16 @@ export function getProjectTreeItemMap(): Map<string, ProjectTreeItem> {
return projectTreeItemMap;
}

export function getPinnedTaskTreeItemMap(): Map<string, GradleTaskTreeItem> {
return pinnedTaskTreeItemMap;
}

function resetCachedTreeItems(): void {
gradleTaskTreeItemMap.clear();
gradleProjectTreeItemMap.clear();
projectTreeItemMap.clear();
groupTreeItemMap.clear();
pinnedTaskTreeItemMap.clear();
}

export class GradleTasksTreeDataProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
Expand Down Expand Up @@ -114,10 +120,12 @@ export class GradleTasksTreeDataProvider implements vscode.TreeDataProvider<vsco
const pinnedTask = cloneTask(this.rootProjectStore, task, args, this.client, definition.javaDebug);
const gradleTaskTreeItem = buildPinnedTaskTreeItem(pinnedTasksItem, pinnedTask, this.icons);
pinnedTasksArray!.push(gradleTaskTreeItem);
pinnedTaskTreeItemMap.set(definition.id, gradleTaskTreeItem);
});
} else {
const gradleTaskTreeItem = buildPinnedTaskTreeItem(pinnedTasksItem, task, this.icons);
pinnedTasksArray.push(gradleTaskTreeItem);
pinnedTaskTreeItemMap.set(definition.id, gradleTaskTreeItem);
}
});
if (pinnedTasksMap.size) {
Expand Down
6 changes: 6 additions & 0 deletions extension/src/views/viewUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getRecentTaskTreeItemMap,
GradleTasksTreeDataProvider,
RecentTasksTreeDataProvider,
getPinnedTaskTreeItemMap,
} from ".";

export function treeItemSortCompareFunc(a: vscode.TreeItem, b: vscode.TreeItem): number {
Expand Down Expand Up @@ -58,6 +59,11 @@ export function updateGradleTreeItemStateForTask(
recentTasksTreeDataProvider: RecentTasksTreeDataProvider
): void {
const definition = task.definition as GradleTaskDefinition;
const pinnedTaskTreeItem = getPinnedTaskTreeItemMap().get(definition.id);
if (pinnedTaskTreeItem) {
pinnedTaskTreeItem.setContext();
gradleTasksTreeDataProvider.refresh(pinnedTaskTreeItem);
}
const gradleTaskTreeItem = getGradleTaskTreeItemMap().get(definition.id);
if (gradleTaskTreeItem) {
gradleTaskTreeItem.setContext();
Expand Down

0 comments on commit e3992ea

Please sign in to comment.