Skip to content

Commit a5ceddc

Browse files
committed
fix(diff-view): streamline tab closing logic in DiffViewProvider
1 parent 92647f7 commit a5ceddc

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,22 +211,14 @@ export class DiffViewProvider {
211211

212212
// If the file was already open, close it (must happen after showing the
213213
// diff view since if it's the only tab the column will close).
214-
this.documentWasOpen = false
215-
216-
// Close the tab if it's open (it's already saved above).
217-
const tabs = vscode.window.tabGroups.all
218-
.map((tg) => tg.tabs)
219-
.flat()
220-
.filter(
221-
(tab) => tab.input instanceof vscode.TabInputText && arePathsEqual(tab.input.uri.fsPath, absolutePath),
222-
)
223-
224-
for (const tab of tabs) {
225-
if (!tab.isDirty) {
226-
await vscode.window.tabGroups.close(tab)
227-
}
228-
this.documentWasOpen = true
229-
}
214+
this.documentWasOpen =
215+
vscode.window.tabGroups.all
216+
.map((tg) => tg.tabs)
217+
.flat()
218+
.filter(
219+
(tab) =>
220+
tab.input instanceof vscode.TabInputText && arePathsEqual(tab.input.uri.fsPath, absolutePath),
221+
).length > 0
230222

231223
this.activeDiffEditor = await this.openDiffEditor()
232224
this.fadedOverlayController = new DecorationController("fadedOverlay", this.activeDiffEditor)

0 commit comments

Comments
 (0)