Skip to content

fix(formatter): remove defaultFormatter dependency for codeActionsOnSave#236

Open
alphatr wants to merge 1 commit into
oxc-project:mainfrom
alphatr:fix/formatter-code-actions-on-save
Open

fix(formatter): remove defaultFormatter dependency for codeActionsOnSave#236
alphatr wants to merge 1 commit into
oxc-project:mainfrom
alphatr:fix/formatter-code-actions-on-save

Conversation

@alphatr
Copy link
Copy Markdown

@alphatr alphatr commented Apr 30, 2026

Summary

Previously, using oxfmt via editor.codeActionsOnSave required setting editor.defaultFormatter to "oxc.oxc-vscode", because the code action relied on VS Code's built-in editor.action.formatDocument command. This change removes that dependency.

What changed

  • Custom format command: Registered oxc.formatDocument that directly calls the LSP textDocument/formatting request via the language client, bypassing the need for editor.defaultFormatter
  • Removed defaultFormatter check: The code actions provider no longer checks whether editor.defaultFormatter is set to "oxc.oxc-vscode"
  • Updated README: Clarified that editor.defaultFormatter is now optional when using codeActionsOnSave, and is only recommended for manual formatting

Test plan

  • source.format.oxc in codeActionsOnSave works without setting editor.defaultFormatter
  • editor.formatOnSave with editor.defaultFormatter set to "oxc.oxc-vscode" still works
  • Manual formatting via Format Document command still works

@Sysix
Copy link
Copy Markdown
Member

Sysix commented May 3, 2026

I do not like adding a second command specific for oxfmt, when the editor does already have a command for formatting.
Do you have any use cases where the defaultFormatter-check needs to be removed?

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.

2 participants