Skip to content

[BUG] DiffViewProvider.open can throw "Tab close: Invalid tab not found!" and abort edits #11362

@0xMink

Description

@0xMink

Problem

DiffViewProvider.open() in src/integrations/editor/DiffViewProvider.ts closes existing editor tabs for the file being edited before opening the diff view. The await vscode.window.tabGroups.close(tab) call at ~line 101 is unguarded — if the tab reference becomes invalid between lookup and close, it throws "Tab close: Invalid tab not found!" and aborts the entire edit operation.

This is best-effort cleanup (the file is already saved before this point). A failure to close an existing tab should not block the edit flow.

Context

Reproduction

Intermittent. More likely in remote/WSL environments. Triggered when a tab reference becomes stale between the filter at line 89 and the close at line 101 of DiffViewProvider.open().

Expected behavior

Tab close failure should be logged and swallowed. The diff view should open and editing should proceed normally.

Suggested fix

Wrap only the tabGroups.close(tab) call in open() with a try-catch, matching the existing pattern in closeAllDiffViews(). The this.documentWasOpen = true assignment must remain unconditional and outside the close success path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions