Skip to content

fix(oxfmt/lsp): revert #19977, prefer file extension over languageId for format strategy#20623

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-22-fix_oxfmt_lsp_revert_19977_prefer_file_extension_over_languageid_for_format_strategy
Mar 23, 2026
Merged

fix(oxfmt/lsp): revert #19977, prefer file extension over languageId for format strategy#20623
graphite-app[bot] merged 1 commit intomainfrom
03-22-fix_oxfmt_lsp_revert_19977_prefer_file_extension_over_languageid_for_format_strategy

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Mar 22, 2026

closes oxc-project/oxc-vscode#140
Preferring the languageID over the real file extension creates inconsistency between the editor and the CLI.
Reverting the changes from #19977 back to align back with CLI.

This only effects file:// scheme, where we can expect a real file on a disk. Other schemes are still preferring the languageID, because we do not to what exactly they are relating to.

Copy link
Member Author

Sysix commented Mar 22, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-bug Category - Bug labels Mar 22, 2026
@Sysix Sysix requested a review from Copilot March 22, 2026 16:37
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 reverts oxfmt’s LSP formatting strategy selection for file:// URIs to align with the CLI by preferring the real file extension over the editor-provided languageId, while continuing to use languageId-based strategy selection for non-file schemes (in-memory documents).

Changes:

  • Revert file:// formatting to select FormatFileStrategy strictly from the on-disk file path/extension.
  • Remove the LSP test case + fixture/snapshot that validated formatting a .txt file as TypeScript via languageId.
  • Simplify LSP module helpers by removing apply_language_id_extension and adjusting fake-path generation for in-memory URIs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/oxfmt/src/lsp/server_formatter.rs Reverts file:// strategy selection to use only the real path extension; keeps language-id-based behavior for non-file URIs.
apps/oxfmt/src/lsp/mod.rs Removes the helper that replaced extensions and updates fake-path creation used for in-memory formatting.
apps/oxfmt/test/lsp/format/format.test.ts Drops the .ts.txt “format as TS” case from file-based formatting tests.
apps/oxfmt/test/lsp/format/fixtures/format/test.ts.txt Removes the no-longer-needed fixture for the reverted behavior.
apps/oxfmt/test/lsp/format/snapshots/format.test.ts.snap Updates snapshots to remove the reverted .ts.txt expectation.

@Sysix Sysix marked this pull request as ready for review March 22, 2026 16:41
@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Mar 23, 2026
Copy link
Member

leaysgur commented Mar 23, 2026

Merge activity

…for format strategy (#20623)

closes oxc-project/oxc-vscode#140
Preferring the languageID over the real file extension creates inconsistency between the editor and the CLI.
Reverting the changes from #19977 back to align back with CLI.

This only effects `file://` scheme, where we can expect a real file on a disk. Other schemes are still preferring the languageID, because we do not to what exactly they are relating to.
@graphite-app graphite-app bot force-pushed the 03-22-fix_oxfmt_lsp_revert_19977_prefer_file_extension_over_languageid_for_format_strategy branch from 4ffee91 to c1b461b Compare March 23, 2026 00:45
@graphite-app graphite-app bot merged commit c1b461b into main Mar 23, 2026
24 checks passed
@graphite-app graphite-app bot deleted the 03-22-fix_oxfmt_lsp_revert_19977_prefer_file_extension_over_languageid_for_format_strategy branch March 23, 2026 00:48
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatter: Different behavior when running from CLI vs IDE format on save

3 participants