Close outdated multidiff editors when PR is reopened
Opening the same PR multiple times can leave outdated multidiff editors open with stale base content. These editors should be closed when the PR is refreshed.
Implementation
Since TabInputMultiDiff is not yet available in the VS Code API (upstream: microsoft/vscode#206411), this uses label-based matching:
-
Added
isKnownTabInputType()helper - Checks if tab input is one of the known types (Text, TextDiff, Custom, Webview, Notebook, NotebookDiff, Terminal). Includes maintenance note for future TabInput types. -
Added
_closeOutdatedMultiDiffEditors()- Identifies multidiff tabs by matching label pattern "Changes in Pull Request #{number}" and verifying tab input is not a known type. Uses for-loops to avoid intermediate arrays. -
Integrated into
_upgradePullRequestEditors()- Closes outdated multidiff editors before upgrading other PR editors.
Example
When a PR is reopened after base branch changes:
// Before: Outdated multidiff editor remains open showing stale diff
// After: Outdated multidiff editor is automatically closed
await this._closeOutdatedMultiDiffEditors(pullRequest);
The label matching depends on the localization key format from PullRequestModel.openChanges() remaining consistent.
Original prompt
This section details on the original issue you should resolve
<issue_title>Close multidiff editors when outdated</issue_title> <issue_description>Opening the same PR again can result in outdated multidiff editors as the left can become out of date. These should be closed when the PR is opened. </issue_description>
Comments on the Issue (you are @copilot in this section)
@alexr00 This requires some work in VS Code core to expose a `TabInputMultiDiff` type in the tabs API, otherwise an extension can't find which tab to close.@alexr00 Upstream issue: https://github.com/microsoft/vscode/issues/206411
- Fixes microsoft/vscode-pull-request-github#5761
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.