-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
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
- The same file already handles this correctly in
closeAllDiffViews(), which swallows close failures gracefully. - VS Code has an upstream regression producing the same error string: Tab list gets corrupted when a new webview is opened (extension API) microsoft/vscode#228270. The trigger there involves webview panel replacement, not identical to this code path, but the defensive posture is the same.
- Reported in [BUG] Roo code won't edit any files - Error apply patch #11358 (closed). The reporter was using VS Code on Windows connected to WSL, where the race window between tab lookup and close is wider due to remote latency.
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.