فهرست منبع

Another grey screen fix. (#3644)

Memory memory memory
xyOz 7 ماه پیش
والد
کامیت
ad9c87a04f
1فایلهای تغییر یافته به همراه19 افزوده شده و 23 حذف شده
  1. 19 23
      src/integrations/editor/DiffViewProvider.ts

+ 19 - 23
src/integrations/editor/DiffViewProvider.ts

@@ -298,21 +298,24 @@ export class DiffViewProvider {
 		await this.reset()
 	}
 
-	private async closeAllDiffViews() {
-		const tabs = vscode.window.tabGroups.all
-			.flatMap((tg) => tg.tabs)
-			.filter(
-				(tab) =>
-					tab.input instanceof vscode.TabInputTextDiff &&
-					tab.input?.original?.scheme === DIFF_VIEW_URI_SCHEME,
-			)
-
-		for (const tab of tabs) {
-			// Trying to close dirty views results in save popup.
-			if (!tab.isDirty) {
-				await vscode.window.tabGroups.close(tab)
+	private async closeAllDiffViews(): Promise<void> {
+		const closeOps = vscode.window.tabGroups.all
+		.flatMap(group => group.tabs)
+		.filter(
+		tab =>
+			tab.input instanceof vscode.TabInputTextDiff &&
+			tab.input.original.scheme === DIFF_VIEW_URI_SCHEME &&
+			!tab.isDirty
+		)
+		.map(tab =>
+		vscode.window.tabGroups.close(tab).then(
+			() => undefined,
+			err => {
+			console.error(`Failed to close diff tab ${tab.label}`, err);
 			}
-		}
+		));
+		
+		await Promise.all(closeOps);
 	}
 
 	private async openDiffEditor(): Promise<vscode.TextEditor> {
@@ -419,15 +422,8 @@ export class DiffViewProvider {
 		return result
 	}
 
-	async reset() {
-		// Ensure any diff views opened by this provider are closed to release
-		// memory.
-		try {
-			await this.closeAllDiffViews()
-		} catch (error) {
-			console.error("Error closing diff views", error)
-		}
-
+	async reset() : Promise<void> {
+		await this.closeAllDiffViews()
 		this.editType = undefined
 		this.isEditing = false
 		this.originalContent = undefined