Skip to content

Conversation

@dmitrivMS
Copy link
Contributor

Fixes #75955

Added include and exclude settings to snippet schema to allow specifying glob patterns for files which the snippet should run on, with semantics similar to files and search settings.

Copilot AI review requested due to automatic review settings December 18, 2025 01:08
@dmitrivMS dmitrivMS self-assigned this Dec 18, 2025
@dmitrivMS dmitrivMS enabled auto-merge (squash) December 18, 2025 01:08
@dmitrivMS dmitrivMS requested a review from jrieken December 18, 2025 01:08
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds glob pattern filtering capabilities to VS Code snippets through new include and exclude settings in the snippet schema. Users can now restrict snippets to specific files using glob patterns similar to those used in files.exclude and search settings.

Key changes:

  • Added include and exclude fields to snippet schema that accept glob patterns
  • Modified snippet selection logic to filter snippets based on file URI matching glob patterns
  • Updated completion provider to pass file URI for pattern matching
  • Added comprehensive test coverage for include/exclude pattern filtering

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/vs/workbench/contrib/snippets/browser/snippetsFile.ts Added include and exclude fields to Snippet class, implemented isFileIncluded() method with glob pattern matching, updated select() method to filter snippets by file URI
src/vs/workbench/contrib/snippets/browser/snippets.ts Updated ISnippetsService interface to add optional resourceUri parameter to getSnippets() and getSnippetsSync() methods
src/vs/workbench/contrib/snippets/browser/snippetsService.ts Updated service implementation to pass resourceUri parameter through to snippet file selection logic
src/vs/workbench/contrib/snippets/browser/snippetCompletionProvider.ts Updated completion provider to pass model.uri when fetching snippets for file-specific filtering
src/vs/workbench/contrib/snippets/browser/snippets.contribution.ts Added JSON schema definitions for include and exclude fields with markdown documentation and examples
src/vs/workbench/contrib/snippets/browser/commands/configureSnippets.ts Updated snippet file templates to include documentation and examples for the new include/exclude patterns
src/vs/workbench/contrib/snippets/test/browser/snippetFile.test.ts Added comprehensive tests for include patterns, exclude patterns, and combined include/exclude scenarios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snippets: Scope by specific file or pattern

2 participants