ruff server: Editor settings are used by default if no file-based configuration exists (#11266)

## Summary

Fixes https://github.com/astral-sh/ruff/issues/11258.

This PR fixes the settings resolver to match the expected behavior when
file-based configuration is not available.

## Test Plan

In a workspace with no file-based configuration, set a setting in your
editor and confirm that this setting is used instead of the default.
This commit is contained in:
Jane Lewis 2024-05-04 10:52:01 -07:00 committed by GitHub
parent 6587dc1269
commit c4bf783b85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,7 +89,15 @@ impl RuffSettingsIndex {
)
.ok()
})
.unwrap_or_default();
.unwrap_or_else(|| {
let default_configuration = ruff_workspace::configuration::Configuration::default();
EditorConfigurationTransformer(editor_settings, root)
.transform(default_configuration)
.into_settings(root)
.expect(
"editor configuration should merge successfully with default configuration",
)
});
Self {
index,