Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 25a81aa

Browse files
committedMay 14, 2025··
fix: refresh patches view when patches on disk change
1 parent 9a79d4c commit 25a81aa

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed
 

‎src/commands/patches.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,15 @@ export function registerPatchesCommands(
115115
vscode.commands.registerCommand(
116116
`${commandPrefix}.patches.remove`,
117117
async (patchTreeItem: Patch) => {
118-
await vscode.workspace.fs.delete(patchTreeItem.resourceUri);
119-
await removePatch(patchTreeItem.resourceUri);
120-
121-
patchesProvider.refresh();
118+
await vscode.window.withProgress(
119+
{ location: { viewId: viewIds.PATCHES } },
120+
async () => {
121+
await Promise.all([
122+
vscode.workspace.fs.delete(patchTreeItem.resourceUri),
123+
removePatch(patchTreeItem.resourceUri),
124+
]);
125+
},
126+
);
122127
},
123128
),
124129
vscode.commands.registerCommand(

‎src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ export async function activate(context: vscode.ExtensionContext) {
403403

404404
const patchesConfig = getPatchesConfigFile(electronRoot);
405405
const patchesProvider = new ElectronPatchesProvider(
406+
context,
406407
electronRoot,
407408
patchesConfig,
408409
);

‎src/views/patches.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,26 @@ export class ElectronPatchesProvider
5353
private readonly rootDirectory: vscode.Uri;
5454
private readonly viewPullRequestTreeItem: ViewPullRequestPatchTreeItem;
5555

56-
constructor(_electronRoot: vscode.Uri, patchesConfig: vscode.Uri) {
56+
constructor(
57+
context: vscode.ExtensionContext,
58+
_electronRoot: vscode.Uri,
59+
patchesConfig: vscode.Uri,
60+
) {
5761
this.rootDirectory = vscode.Uri.joinPath(_electronRoot, "..", "..");
5862
this.patchesConfig = parsePatchConfig(patchesConfig);
5963

6064
this.viewPullRequestTreeItem = new ViewPullRequestPatchTreeItem();
65+
66+
const fsWatcher = vscode.workspace.createFileSystemWatcher(
67+
new vscode.RelativePattern(_electronRoot, "patches/**"),
68+
);
69+
70+
context.subscriptions.push(
71+
fsWatcher,
72+
fsWatcher.onDidChange(() => this.refresh()),
73+
fsWatcher.onDidCreate(() => this.refresh()),
74+
fsWatcher.onDidDelete(() => this.refresh()),
75+
);
6176
}
6277

6378
refresh(): void {

0 commit comments

Comments
 (0)
Please sign in to comment.