Repository navigation
Cancel stale format-on-type requests - #347115
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits intoNov 12, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No actionable review findings remain for the change that ties pending format-on-type requests to the editor’s formatting session.
No open issues 🎉
What changed in this PR
Fixes #347114 by tying pending format-on-type requests to the editor’s formatting session, preventing delayed responses from editing a different document after a tab switch.
Changes:
- Cancel pending requests when the formatting session ends and remove completed requests from session tracking.
- Add unit coverage for model switching, cancellation, disposal, and successful formatting.
- Add a public API regression test for switching documents while formatting is pending.
No actionable findings remain.
| File | Description |
|---|---|
src/vs/workbench/contrib/format/test/browser/formatActionsMultiple.test.ts |
Adds format-on-type lifecycle and regression tests. |
src/vs/editor/contrib/format/browser/formatActions.ts |
Binds request cancellation and cleanup to the formatting session. |
extensions/vscode-api-tests/src/singlefolder-tests/editor.test.ts |
Tests delayed formatting across a same-group document switch. |
Review effort: Balanced
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
November 12, 2026 01:29
Collaborator
|
Sameer (@sameerihs) Thank you! |
Dmitriy Vasyura (dmitrivMS)
previously approved these changes
Nov 12, 2026
Retain the browser regressions for microsoft#347114 without relying on global editor focus left by earlier Chat API tests. Remove the duplicate API scenario and its unused imports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 12, 2026
roblourens
approved these changes
Nov 12, 2026
Dmitriy Vasyura (dmitrivMS)
merged commit Nov 12, 2026
3404e94
into
microsoft:main
52 of 53 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #347114
A delayed format-on-type response can edit a different document after the user switches tabs in the same editor group. Bind each pending request to the formatting session so model, configuration or provider changes cancel it. Remove completed requests from session tracking.
The browser regressions fail before the fix and pass afterward. The public reproduction also fails in installed VS Code 1.145.2: whitespace intended for
const x=1;splits the other document's identifier intoconst v a lue=2;.Controls cover successful formatting, switching back to the original document and cancellation/disposal. Original macOS validation included client and API-extension compilation, client typechecking and changed-file lint.
CI follow-up
Remove the duplicate public-API regression and its unused imports. In the full API suite, the global
typecommand can target a stale Chat editor left by earlier tests instead of the test document, so its formatter never starts. The retained browser tests cover the same cancellation behavior without depending on global focus. No production Chat/editor-focus behavior or SSH smoke automation is changed.Additional Windows validation
Commands were run with
VSCODE_SKIP_PRELAUNCH=1for the test scripts:pnpm run build-fast- passed;pnpm run build-fast --client-onlyalso passed after incorporating the latest incoming main merge.node build\hygiene.ts extensions\vscode-api-tests\src\singlefolder-tests\editor.test.ts- passed, including targeted oxlint..\scripts\test.bat --run src\vs\workbench\contrib\format\test\browser\formatActionsMultiple.test.ts --reporter dot- 9 passing. Running the same command with only the compiled controller temporarily replaced by its pre-fix version produced 5 passing controls and 4 expected regression failures. The fixed output was restored and hash-verified, then all 9 passed again..\scripts\test-integration.bat --suite api-folder --grep '^(chat|vscode API - editors)'- 28 passing, 14 pending..\scripts\test-integration.bat --suite api-folder- 340 passing, 58 pending, 2 failures in unchanged tests: the active-editor assertion for active editor not always correct... #49125 and the no-output terminal assertion for Commands with no output show the sandbox command instead of "no output" #303531. The formatter-start timeout is eliminated; these unrelated failures were not modified.