-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use fallback settings when indexing the project #12362
Conversation
|
); | ||
return WalkState::Continue; | ||
} | ||
.map(|(_, settings)| settings.clone()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these clones necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are all Arc<RuffSettings>
so this should be cheap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these are all Arc
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It otherwise throws "rustc: temporary value dropped while borrowed" if I use a reference
let settings = index
.read()
.unwrap()
.range(..directory.clone())
.rfind(|(path, _)| directory.starts_with(path))
.map(|(_, settings)| settings)
.unwrap_or(&fallback);
); | ||
return WalkState::Continue; | ||
} | ||
.map(|(_, settings)| settings.clone()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are all Arc<RuffSettings>
so this should be cheap.
Summary
This PR updates the settings index building logic in the language server to consider the fallback settings for applying ignore filters in
WalkBuilder
and the exclusion viaexclude
/extend-exclude
.This flow matches the one in the
ruff
CLI where the root settings is built by (1) finding the workspace setting in the ancestor directory (2) finding the user configuration if that's missing and (3) fallback to using the default configuration.Previously, the index building logic was being executed before (2) and (3). This PR reverses the logic so that the exclusion /
respect_gitignore
is being considered from the default settings if there's no workspace / user settings. This has the benefit that the server no longer enters the.git
directory or any other excluded directory when a user opens a file in the home directory.Related to #11366
Test plan
Opened a test file from the home directory and confirmed with the debug trace (removed in #12360) that the server excludes the
.git
directory when indexing.