Fix: cancel snippet tab stops on delimiter chars in query playground#590
Merged
tnaum-ms merged 3 commits intorel/release_0.8.0from Apr 17, 2026
Merged
Fix: cancel snippet tab stops on delimiter chars in query playground#590tnaum-ms merged 3 commits intorel/release_0.8.0from
tnaum-ms merged 3 commits intorel/release_0.8.0from
Conversation
Port the collection view's cancelSnippetSession behavior to the
query playground. When a user types a delimiter character (`,`, `}`, `]`)
while a snippet tab stop is active, the snippet session is now cancelled
via the built-in `leaveSnippet` command.
Previously, accepting a snippet completion (e.g., `{ \$exists: <tabstop> }`)
and filling in the value left the tab stop active indefinitely — typing
delimiters, spaces, or even pressing Escape (consumed by the suggest
widget) would not exit the snippet.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Ports the “cancel snippet session on delimiter characters” behavior from the Collection View query editor to the native VS Code query playground, preventing snippet tab-stop highlights from persisting (“ghost selection”) after snippet completion acceptance.
Changes:
- Added a
PlaygroundSnippetSessionManagerthat listens to playground document edits and triggers VS Code’sleaveSnippetcommand when delimiter characters are typed. - Registered the new manager during extension activation alongside existing playground completion/hover providers.
- Added a Jest test suite covering delimiter vs non-delimiter edits and playground vs non-playground documents.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/documentdb/query-language/playground-completions/tdd/playgroundSnippetSessionManager.test.ts | New unit tests for snippet-session exit behavior in playground documents. |
| src/documentdb/query-language/playground-completions/PlaygroundSnippetSessionManager.ts | New manager that exits snippet mode on delimiter keystrokes in playground editors. |
| src/documentdb/ClustersExtension.ts | Registers the new snippet session manager during extension setup. |
- Remove inaccurate 'or Enter is pressed' from class doc comment - Add activeTextEditor guard to prevent leaveSnippet in wrong editor - Move jest.mock() before imports per repo convention - Add test for active editor document mismatch scenario
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.
Summary
Ports the collection view's
cancelSnippetSessionbehavior to the query playground so that snippet tab stops are proactively closed when delimiter characters are typed.Problem
When a user accepts a snippet completion in the playground (e.g.
{ $exists: <tabstop> }), the tab stop remained active indefinitely. Typing,,},], space, or pressing Escape did not exit the snippet — the "ghost selection" bug that was already fixed in the collection view.Solution
New
PlaygroundSnippetSessionManagerthat listens foronDidChangeTextDocumenton playground files and executes the built-inleaveSnippetcommand when a single-character delimiter (,,},]) is typed — mirroring the collection view'sSNIPPET_EXIT_CHARSlogic.The collection view uses Monaco's internal
snippetController2.cancel()(webview), while the playground uses VS Code's nativeleaveSnippetcommand (extension host editor).Files changed
PlaygroundSnippetSessionManager.ts— new manager classClustersExtension.ts— register the manager alongside existing playground providersplaygroundSnippetSessionManager.test.ts— 9 unit tests covering all delimiter/non-delimiter/non-playground cases