Skip to content

fix(lsp): fmt.configPath empty string handling#17425

Merged
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-configpath-setting
Dec 28, 2025
Merged

fix(lsp): fmt.configPath empty string handling#17425
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-configpath-setting

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

This PR fixes the handling of empty string values in the fmt.configPath setting for the formatter service, mirroring the fix made for the linter in PR #17415. When VS Code's settings UI auto-generates "fmt.configPath": "", the formatter now treats this as if no config path was specified and falls back to searching for default config files (.oxfmtrc.json and .oxfmtrc.jsonc) instead of failing to initialize.

Copilot AI changed the title [WIP] Fix configPath setting for server formatter Fix formatter configPath to match linter pattern Dec 28, 2025
Copilot AI requested a review from Sysix December 28, 2025 14:58
@Sysix
Copy link
Member

Sysix commented Dec 28, 2025

@copilot No do not rename fmt.configPath to configPath. You should look into #17388 this fixes configPath with empty string, you should fix fmt.configPath the same, so it check empty string and fallsback to default config

Copy link
Contributor Author

Copilot AI commented Dec 28, 2025

@copilot No do not rename fmt.configPath to configPath. You should look into #17388 this fixes configPath with empty string, you should fix `fmt.configPath...

You're right, I misunderstood the issue. I've reverted the rename and instead added empty string handling to fmt.configPath similar to the linter's pattern. When fmt.configPath is an empty string, it now falls back to the default config files (.oxfmtrc.json, .oxfmtrc.jsonc).

Changes in commit 81803f9:

  • Added .filter(|s| !s.is_empty()) to search_config_file and get_watcher_patterns methods
  • Added tests for empty string handling
  • All 140 tests pass

Copilot AI changed the title Fix formatter configPath to match linter pattern Fix fmt.configPath empty string handling Dec 28, 2025
@github-actions github-actions bot added the A-editor Area - Editor and Language Server label Dec 28, 2025
@Sysix Sysix changed the title Fix fmt.configPath empty string handling fix(lsp): fmt.configPath empty string handling Dec 28, 2025
@github-actions github-actions bot added the C-bug Category - Bug label Dec 28, 2025
@Sysix
Copy link
Member

Sysix commented Dec 28, 2025

@copilot fix the CI lint errors

Copy link
Contributor Author

Copilot AI commented Dec 28, 2025

@copilot fix the CI lint errors

Fixed the clippy lint error in commit be7afc5. Changed "".to_string() to String::new() in the test assertion.

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 fixes the handling of empty string values in the fmt.configPath setting for the formatter service, mirroring the fix made for the linter in PR #17415. When VS Code's settings UI auto-generates "fmt.configPath": "", the formatter now treats this as if no config path was specified and falls back to searching for default config files (.oxfmtrc.json and .oxfmtrc.jsonc) instead of failing to initialize.

  • Applied empty string filtering using .filter(|s| !s.is_empty()) in both config search and file watcher pattern generation
  • Added comprehensive tests to verify empty string handling in both formatter options and watcher patterns
  • Fixed clippy lint by using String::new() instead of "".to_string()

Reviewed changes

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

File Description
crates/oxc_language_server/src/formatter/server_formatter.rs Added `.filter(
crates/oxc_language_server/src/formatter/options.rs Added test to verify that empty string config paths are properly parsed and stored as Some(String::new())

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sysix Sysix marked this pull request as ready for review December 28, 2025 15:28
@Sysix Sysix requested a review from camc314 as a code owner December 28, 2025 15:28
@Sysix Sysix added the 0-merge Merge with Graphite Merge Queue label Dec 28, 2025
Copy link
Member

Sysix commented Dec 28, 2025

Merge activity

> This PR fixes the handling of empty string values in the fmt.configPath setting for the formatter service, mirroring the fix made for the linter in PR #17415. When VS Code's settings UI auto-generates "fmt.configPath": "", the formatter now treats this as if no config path was specified and falls back to searching for default config files (.oxfmtrc.json and .oxfmtrc.jsonc) instead of failing to initialize.
@graphite-app graphite-app bot force-pushed the copilot/fix-configpath-setting branch from be7afc5 to 786a505 Compare December 28, 2025 17:04
@graphite-app graphite-app bot merged commit 786a505 into main Dec 28, 2025
21 of 22 checks passed
@graphite-app graphite-app bot deleted the copilot/fix-configpath-setting branch December 28, 2025 17:09
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants