Skip to content

Commit

Permalink
Consider nested configs for settings reloading (#12253)
Browse files Browse the repository at this point in the history
## Summary

This PR fixes a bug in the settings reloading logic to consider nested
configuration in a workspace.

fixes: #11766

## Test Plan


https://github.com/astral-sh/ruff/assets/67177269/69704b7b-44b9-4cc7-b5a7-376bf87c6ef4
  • Loading branch information
dhruvmanila committed Jul 12, 2024
1 parent bd01004 commit 90e9aae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/ruff_server/src/session/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ impl Index {
}

/// Reloads relevant existing settings files based on a changed settings file path.
/// This does not currently register new settings files.
pub(super) fn reload_settings(&mut self, changed_url: &Url) {
let Ok(changed_path) = changed_url.to_file_path() else {
// Files that don't map to a path can't be a workspace configuration file.
Expand All @@ -310,10 +309,12 @@ impl Index {
return;
};

// TODO: I think this does not correctly reload settings when using `extend` and the extended
// setting isn't in a parent folder.
for (root, settings) in self.settings.range_mut(enclosing_folder.to_path_buf()..) {
if !root.starts_with(enclosing_folder) {
for (root, settings) in self
.settings
.range_mut(..=enclosing_folder.to_path_buf())
.rev()
{
if !enclosing_folder.starts_with(root) {
break;
}

Expand Down

0 comments on commit 90e9aae

Please sign in to comment.