fix(formatter): remove defaultFormatter dependency for codeActionsOnSave#236
fix(formatter): remove defaultFormatter dependency for codeActionsOnSave#236alphatr wants to merge 1 commit into
Conversation
|
I do not like adding a second command specific for oxfmt, when the editor does already have a command for formatting. |
|
The core issue is about supporting a gradual migration path to oxc without requiring per-project VS Code settings changes. The ideal setup is to configure once at the global level: {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"oxc.fmt.requireConfig": true,
"editor.codeActionsOnSave": {
"source.format.oxc": "always",
"source.fixAll.oxc": "always"
}
}With This makes migration a one-step operation driven entirely by the project's own config files, not by VS Code settings management. The per-folder This PR is one piece of that picture: |
Summary
Previously, using oxfmt via
editor.codeActionsOnSaverequired settingeditor.defaultFormatterto"oxc.oxc-vscode", because the code action relied on VS Code's built-ineditor.action.formatDocumentcommand. This change removes that dependency.What changed
oxc.formatDocumentthat directly calls the LSPtextDocument/formattingrequest via the language client, bypassing the need foreditor.defaultFormatterdefaultFormattercheck: The code actions provider no longer checks whethereditor.defaultFormatteris set to"oxc.oxc-vscode"editor.defaultFormatteris now optional when usingcodeActionsOnSave, and is only recommended for manual formattingTest plan
source.format.oxcincodeActionsOnSaveworks without settingeditor.defaultFormattereditor.formatOnSavewitheditor.defaultFormatterset to"oxc.oxc-vscode"still worksFormat Documentcommand still works