fix: resolve diff editor timeout issue when file is pre-opened (#6199) #6200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the diff editor timeout issue that started appearing in v3.20.3, where users would get the error "Failed to open diff editor within 10 seconds. The editor may be blocked or VS Code may be unresponsive."
Problem
The issue was introduced when trying to fix markdown preview associations by pre-opening files as text documents. When a file is pre-opened, the subsequent diff command might not trigger the expected
onDidOpenTextDocumentevent because the document is already open, causing the 10-second timeout to trigger.Solution
Added an immediate check for visible diff editor after the diff command execution. This handles cases where the document was pre-opened and events might not fire as expected.
Changes
openDiffEditor()method inDiffViewProvider.tsto check if the diff editor is already visible after executing the diff commandTesting
Fixes #6199
Important
Fixes diff editor timeout in
DiffViewProvider.tsby checking editor visibility post-command execution, with a new test added.openDiffEditor()inDiffViewProvider.tsby checking if the diff editor is visible after executing the diff command.DiffViewProvider.spec.tsto verify immediate resolution when the diff editor is already visible.DiffViewProvider.ts.This description was created by
for 3d9d0ae. You can customize this summary. It will automatically update as commits are pushed.