Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

Description

Implements OnTypeFormattingEditProvider with ; and } triggers. Enhances all formatting providers with cancellation token support.

On-Type Formatting

  • Triggers on ; (semicolon) and } (closing brace)
  • Validates trigger character at exact cursor position
  • Only formats when trigger is at end of line (prevents mid-edit formatting)
  • Controlled via standard VS Code editor.formatOnType setting

Cancellation Token Support

  • Added to PrettierEditProvider (document/range formatting)
  • Added to PrettierOnTypeFormattingEditProvider
  • Added to PrettierCodeActionProvider
  • Checks cancellation before and after format operations

Files

  • src/PrettierOnTypeFormattingEditProvider.ts - New provider implementation
  • src/PrettierEditService.ts - Provider registration and cancellation plumbing
  • src/PrettierEditProvider.ts - Cancellation support
  • src/PrettierCodeActionProvider.ts - Cancellation support
  • src/test/suite/onTypeFormatting.test.ts - Test coverage
  • docs/on-type-formatting.md - User documentation

Related Issue

Fixes #3652

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/Build changes

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project (npm run lint passes)
  • I have run npm run prettier to format my code
  • I have added/updated tests that prove my fix or feature works
  • All new and existing tests pass (npm test)
  • I have updated the CHANGELOG.md with a summary of my changes
Original prompt

This section details on the original issue you should resolve

<issue_title>Add on type formatting</issue_title>
<issue_description>Implement on type code formatting (https://code.visualstudio.com/api/references/vscode-api#OnTypeFormattingEditProvider) and review the implementation of the range edit provider for any improvements that could be made.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 2, 2025
Copilot AI and others added 3 commits December 2, 2025 00:39
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
…arity

Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Copilot AI changed the title [WIP] Add on type code formatting and review range edit provider Add on-type formatting with cancellation token support Dec 2, 2025
Copilot AI requested a review from ntotten December 2, 2025 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add on type formatting

2 participants